2024-09-07 20:25:22 +08:00
|
|
|
#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
|
2022-08-05 10:21:54 +02:00
|
|
|
|
2023-09-20 16:53:05 +02:00
|
|
|
WORKDIR /app
|
2017-04-22 20:29:25 +02:00
|
|
|
|
2024-04-22 09:51:02 +02:00
|
|
|
VOLUME /app/var/
|
|
|
|
|
2019-06-27 12:03:08 +02:00
|
|
|
# persistent / runtime deps
|
2024-03-07 14:20:51 +01:00
|
|
|
# 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; \
|
2023-10-04 11:28:49 +03:00
|
|
|
install-php-extensions \
|
2024-01-11 11:04:24 +01:00
|
|
|
@composer \
|
2023-04-18 16:19:51 +02:00
|
|
|
apcu \
|
|
|
|
intl \
|
2021-01-04 20:05:15 +01:00
|
|
|
opcache \
|
2023-04-18 16:19:51 +02:00
|
|
|
zip \
|
2023-10-04 11:28:49 +03:00
|
|
|
;
|
2017-04-22 20:29:25 +02:00
|
|
|
|
2024-01-11 11:04:24 +01:00
|
|
|
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
|
|
|
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
|
|
|
|
2024-08-07 14:37:07 +02:00
|
|
|
ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d"
|
|
|
|
|
2022-08-05 10:21:54 +02:00
|
|
|
###> recipes ###
|
2025-02-13 13:39:42 +03:00
|
|
|
###> doctrine/doctrine-bundle ###
|
|
|
|
RUN install-php-extensions pdo_pgsql
|
|
|
|
###< doctrine/doctrine-bundle ###
|
2022-08-05 10:21:54 +02:00
|
|
|
###< recipes ###
|
2019-12-03 21:00:08 +01:00
|
|
|
|
2024-08-07 14:37:07 +02: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
|
2022-08-05 10:21:54 +02:00
|
|
|
|
|
|
|
ENTRYPOINT ["docker-entrypoint"]
|
2019-12-03 21:00:08 +01:00
|
|
|
|
2023-10-26 14:49:28 +02: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 \
|
2023-10-04 11:28:49 +03:00
|
|
|
xdebug \
|
2025-02-13 13:39:42 +03:00
|
|
|
pgsql \
|
2023-10-04 11:28:49 +03:00
|
|
|
;
|
2023-07-31 14:21:06 +02:00
|
|
|
|
2024-08-07 14:37:07 +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
|
|
|
|
2024-08-07 14:37:07 +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
|
2021-06-14 15:12:18 +02:00
|
|
|
|
2022-08-05 10:21:54 +02:00
|
|
|
# prevent the reinstallation of vendors at every changes in the source code
|
2022-12-21 09:54:34 +01:00
|
|
|
COPY --link composer.* symfony.* ./
|
2022-08-05 10:21:54 +02:00
|
|
|
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
|
|
|
|
2022-08-05 10:21:54 +02: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;
|