forum/Dockerfile

100 lines
2.6 KiB
Docker
Raw Normal View History

#syntax=docker/dockerfile:1
2022-10-17 11:17:15 +02:00
2023-07-31 14:21:06 +02:00
# Versions
2025-02-13 13:39:42 +03:00
FROM dunglas/frankenphp:1-php8.4 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
VOLUME /app/var/
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
ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d"
###> recipes ###
2025-02-13 13:39:42 +03:00
###> doctrine/doctrine-bundle ###
RUN install-php-extensions pdo_pgsql
###< doctrine/doctrine-bundle ###
###< recipes ###
2019-12-03 21:00:08 +01:00
COPY --link frankenphp/conf.d/10-app.ini $PHP_INI_DIR/app.conf.d/
2023-09-20 16:53:05 +02:00
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
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN set -eux; \
install-php-extensions \
xdebug \
2025-02-13 13:39:42 +03:00
pgsql \
;
2023-07-31 14:21:06 +02:00
COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.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/20-app.prod.ini $PHP_INI_DIR/app.conf.d/
2023-09-20 16:53:05 +02:00
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; \
2025-02-13 18:25:14 +03:00
chmod +x bin/console; \
sync;