domain-watchdog/Dockerfile

106 lines
2.9 KiB
Docker
Raw Permalink Normal View History

2024-08-11 20:24:04 +02:00
# syntax=docker/dockerfile:1.4
2024-08-11 15:43:30 +02:00
# Versions
2025-10-27 18:03:14 +01:00
FROM dunglas/frankenphp:1-php8.4 AS frankenphp_upstream
2024-08-11 15:43:30 +02:00
# The different stages of this Dockerfile are meant to be built into separate images
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
# https://docs.docker.com/compose/compose-file/#target
# Base FrankenPHP image
FROM frankenphp_upstream AS frankenphp_base
WORKDIR /app
VOLUME /app/var/
# persistent / runtime deps
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
2024-08-11 20:24:04 +02:00
file \
2025-01-27 21:55:51 +01:00
libicu-dev \
libzip-dev \
unzip \
g++ \
2024-08-11 20:24:04 +02:00
&& rm -rf /var/lib/apt/lists/*
RUN set -eux; \
install-php-extensions \
@composer \
apcu \
intl \
opcache \
zip
2024-08-11 15:43:30 +02:00
RUN set -eux; \
2024-08-11 20:24:04 +02:00
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -; \
apt-get install -y nodejs; \
npm install -g yarn
2024-08-11 15:43:30 +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 ###
2024-08-11 16:11:20 +02:00
###> doctrine/doctrine-bundle ###
RUN install-php-extensions pdo_pgsql
###< doctrine/doctrine-bundle ###
2024-08-11 15:43:30 +02:00
###< recipes ###
COPY --link frankenphp/conf.d/10-app.ini $PHP_INI_DIR/app.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"]
HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]
# Dev FrankenPHP image
FROM frankenphp_base AS frankenphp_dev
ENV APP_ENV=dev XDEBUG_MODE=off
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN set -eux; \
2024-08-11 20:24:04 +02:00
install-php-extensions \
xdebug
2024-08-11 15:43:30 +02:00
COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ]
# Prod FrankenPHP image
FROM frankenphp_base AS frankenphp_prod
ENV APP_ENV=prod
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --link frankenphp/conf.d/20-app.prod.ini $PHP_INI_DIR/app.conf.d/
COPY --link frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile
# prevent the reinstallation of vendors at every changes in the source code
COPY --link composer.* symfony.* ./
RUN set -eux; \
2024-08-22 22:03:04 +02:00
install-php-extensions redis; \
2024-08-11 20:24:04 +02:00
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
2024-08-11 15:43:30 +02:00
# copy sources
COPY --link . ./
RUN rm -Rf frankenphp/
RUN set -eux; \
2024-08-11 20:24:04 +02:00
mkdir -p var/cache var/log; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; \
2024-08-13 13:37:34 +02:00
php bin/console assets:install; \
yarn install; \
yarn run build; \
yarn run ttag:po2json; \
rm -rf node_modules; \
2024-08-13 13:37:34 +02:00
sync