forum/Dockerfile

92 lines
2.4 KiB
Docker
Raw Normal View History

2022-10-17 11:17:15 +02:00
#syntax=docker/dockerfile:1.4
2023-07-31 14:21:06 +02:00
# Versions
FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream
2023-07-31 14:21:06 +02:00
2022-10-17 11:17:15 +02:00
# The different stages of this Dockerfile are meant to be built into separate images
2019-06-27 12:03:08 +02:00
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
2018-06-25 00:21:05 +02:00
# https://docs.docker.com/compose/compose-file/#target
2022-12-21 09:54:34 +01:00
2023-09-20 16:53:05 +02:00
# Base FrankenPHP image
FROM frankenphp_upstream AS frankenphp_base
2023-09-20 16:53:05 +02:00
WORKDIR /app
2017-04-22 20:29:25 +02:00
2019-06-27 12:03:08 +02:00
# persistent / runtime deps
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
acl \
file \
gettext \
git \
&& rm -rf /var/lib/apt/lists/*
2019-12-03 21:00:08 +01:00
2019-06-27 12:03:08 +02:00
RUN set -eux; \
install-php-extensions \
@composer \
apcu \
intl \
opcache \
zip \
;
2017-04-22 20:29:25 +02:00
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER=1
###> recipes ###
###< recipes ###
2019-12-03 21:00:08 +01:00
2023-09-20 16:53:05 +02:00
COPY --link frankenphp/conf.d/app.ini $PHP_INI_DIR/conf.d/
COPY --link --chmod=755 frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY --link frankenphp/Caddyfile /etc/caddy/Caddyfile
ENTRYPOINT ["docker-entrypoint"]
2019-12-03 21:00:08 +01:00
HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1
2023-09-20 16:53:05 +02:00
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]
2023-07-31 14:21:06 +02:00
2023-09-20 16:53:05 +02:00
# Dev FrankenPHP image
FROM frankenphp_base AS frankenphp_dev
2023-07-31 14:21:06 +02:00
ENV APP_ENV=dev XDEBUG_MODE=off
2023-09-20 16:53:05 +02:00
VOLUME /app/var/
2023-07-31 14:21:06 +02:00
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN set -eux; \
install-php-extensions \
xdebug \
;
2023-07-31 14:21:06 +02:00
2023-09-20 16:53:05 +02:00
COPY --link frankenphp/conf.d/app.dev.ini $PHP_INI_DIR/conf.d/
2023-07-31 14:21:06 +02:00
2023-09-20 16:53:05 +02:00
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]
# Prod FrankenPHP image
FROM frankenphp_base AS frankenphp_prod
2023-07-31 14:21:06 +02:00
ENV APP_ENV=prod
2023-09-20 16:53:05 +02:00
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
2023-07-31 14:21:06 +02:00
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
2023-09-20 16:53:05 +02:00
COPY --link frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/
COPY --link frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile
# prevent the reinstallation of vendors at every changes in the source code
2022-12-21 09:54:34 +01:00
COPY --link composer.* symfony.* ./
RUN set -eux; \
2023-07-31 14:21:06 +02:00
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
2017-11-22 08:52:31 +01:00
# copy sources
2023-07-31 14:21:06 +02:00
COPY --link . ./
2023-09-20 16:53:05 +02:00
RUN rm -Rf frankenphp/
2017-04-22 20:29:25 +02:00
2019-06-27 12:03:08 +02:00
RUN set -eux; \
mkdir -p var/cache var/log; \
2023-07-31 14:21:06 +02:00
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; sync;