-
Notifications
You must be signed in to change notification settings - Fork 0
WIP: apip 4 and frankenphp migrations #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,106 +1,96 @@ | ||
| # the different stages of this Dockerfile are meant to be built into separate images | ||
| #syntax=docker/dockerfile:1 | ||
|
|
||
| # Versions | ||
| FROM dunglas/frankenphp:1-php8.4 AS frankenphp_upstream | ||
|
|
||
| # 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 | ||
|
|
||
|
|
||
| # https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact | ||
| ARG PHP_VERSION=8.2 | ||
| ARG CADDY_VERSION=2.7 | ||
| # Base FrankenPHP image | ||
| FROM frankenphp_upstream AS frankenphp_base | ||
|
|
||
| # "php" stage | ||
| FROM php:${PHP_VERSION}-fpm-alpine AS symfony_php | ||
| WORKDIR /app | ||
|
|
||
| # php extensions installer: https://github.com/mlocati/docker-php-extension-installer | ||
| COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ | ||
| VOLUME /app/var/ | ||
|
|
||
| # persistent / runtime deps | ||
| RUN apk add --no-cache \ | ||
| acl \ | ||
| fcgi \ | ||
| file \ | ||
| gettext \ | ||
| git \ | ||
| ; | ||
| # hadolint ignore=DL3008 | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| file \ | ||
| git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN set -eux; \ | ||
| install-php-extensions \ | ||
| intl \ | ||
| zip \ | ||
| @composer \ | ||
| apcu \ | ||
| pdo_pgsql \ | ||
| intl \ | ||
| opcache \ | ||
| zip \ | ||
| ; | ||
|
|
||
| # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser | ||
| ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
|
|
||
| # Transport to use by Mercure (default to Bolt) | ||
| ENV MERCURE_TRANSPORT_URL=bolt:///data/mercure.db | ||
|
|
||
| ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d" | ||
|
|
||
| ###> recipes ### | ||
| ###> doctrine/doctrine-bundle ### | ||
| RUN set -eux; \ | ||
| install-php-extensions pdo_pgsql | ||
| ###< doctrine/doctrine-bundle ### | ||
| ###< recipes ### | ||
|
|
||
| COPY docker/php/docker-healthcheck.sh /usr/local/bin/docker-healthcheck | ||
| RUN chmod +x /usr/local/bin/docker-healthcheck | ||
| COPY --link docker/php/conf.d/symfony.dev.ini $PHP_INI_DIR/app.conf.d/ | ||
| COPY --link --chmod=755 docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint | ||
| COPY --link docker/caddy/Caddyfile /etc/frankenphp/Caddyfile | ||
|
|
||
| HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD ["docker-healthcheck"] | ||
| ENTRYPOINT ["docker-entrypoint"] | ||
|
|
||
| RUN ln -s $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini | ||
| COPY docker/php/conf.d/symfony.prod.ini $PHP_INI_DIR/conf.d/symfony.ini | ||
| HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1 | ||
| CMD [ "frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile" ] | ||
|
|
||
| COPY docker/php/php-fpm.d/zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf | ||
| # Dev FrankenPHP image | ||
| FROM frankenphp_base AS frankenphp_dev | ||
|
|
||
| COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint | ||
| RUN chmod +x /usr/local/bin/docker-entrypoint | ||
| ENV APP_ENV=dev | ||
| ENV XDEBUG_MODE=off | ||
| ENV FRANKENPHP_WORKER_CONFIG=watch | ||
|
|
||
| VOLUME /var/run/php | ||
| RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" | ||
|
|
||
| COPY --from=composer/composer:2-bin /composer /usr/bin/composer | ||
| RUN set -eux; \ | ||
| install-php-extensions \ | ||
| xdebug \ | ||
| ; | ||
|
|
||
| # https://getcomposer.org/doc/03-cli.md#composer-allow-superuser | ||
| ENV COMPOSER_ALLOW_SUPERUSER=1 | ||
| COPY --link docker/php/conf.d/symfony.dev.ini $PHP_INI_DIR/app.conf.d/ | ||
|
|
||
| ENV PATH="${PATH}:/root/.composer/vendor/bin" | ||
| CMD [ "frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile", "--watch" ] | ||
|
|
||
| WORKDIR /srv/app | ||
| # Prod FrankenPHP image | ||
| FROM frankenphp_base AS frankenphp_prod | ||
|
|
||
| # Allow to choose skeleton | ||
| ARG SKELETON="symfony/skeleton" | ||
| ENV SKELETON ${SKELETON} | ||
| ENV APP_ENV=prod | ||
|
|
||
| # Allow to use development versions of Symfony | ||
| ARG STABILITY="stable" | ||
| ENV STABILITY ${STABILITY} | ||
| RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | ||
|
|
||
| # Allow to select skeleton version | ||
| ARG SYMFONY_VERSION="" | ||
| ENV SYMFONY_VERSION ${SYMFONY_VERSION} | ||
| COPY --link docker/php/conf.d/symfony.prod.ini $PHP_INI_DIR/app.conf.d/ | ||
|
|
||
| # Download the Symfony skeleton and leverage Docker cache layers | ||
| RUN composer create-project "${SKELETON} ${SYMFONY_VERSION}" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-interaction; \ | ||
| composer clear-cache | ||
| # prevent the reinstallation of vendors at every changes in the source code | ||
| COPY --link composer.* symfony.* ./ | ||
| RUN set -eux; \ | ||
| composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress | ||
|
|
||
| COPY . . | ||
| # copy sources | ||
| COPY --link . ./ | ||
| RUN rm -Rf frankenphp/ | ||
|
|
||
| RUN set -eux; \ | ||
| mkdir -p var/cache var/log; \ | ||
| composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction; \ | ||
| composer dump-autoload --classmap-authoritative --no-dev; \ | ||
| composer symfony:dump-env prod; \ | ||
| composer dump-env prod; \ | ||
| composer run-script --no-dev post-install-cmd; \ | ||
| chmod +x bin/console; sync | ||
| VOLUME /srv/app/var | ||
|
|
||
| ENTRYPOINT ["docker-entrypoint"] | ||
| CMD ["php-fpm"] | ||
|
|
||
| FROM caddy:${CADDY_VERSION}-builder-alpine AS symfony_caddy_builder | ||
|
|
||
| RUN xcaddy build \ | ||
| --with github.com/dunglas/mercure/caddy \ | ||
| --with github.com/dunglas/vulcain/caddy | ||
|
|
||
| FROM caddy:${CADDY_VERSION} AS symfony_caddy | ||
|
|
||
| WORKDIR /srv/app | ||
|
|
||
| COPY --from=symfony_caddy_builder /usr/bin/caddy /usr/bin/caddy | ||
| COPY --from=symfony_php /srv/app/public public/ | ||
| COPY docker/caddy/Caddyfile /etc/caddy/Caddyfile | ||
| chmod +x bin/console; sync; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||||||||||||||||||||||
| services: | ||||||||||||||||||||||||||
| php: | ||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||
| context: . | ||||||||||||||||||||||||||
| target: frankenphp_dev | ||||||||||||||||||||||||||
| volumes: | ||||||||||||||||||||||||||
| - ./:/app | ||||||||||||||||||||||||||
| - ./docker/caddy/Caddyfile:/etc/frankenphp/Caddyfile:ro | ||||||||||||||||||||||||||
| - ./docker/php/conf.d/symfony.dev.ini:/usr/local/etc/php/app.conf.d/symfony.dev.ini:ro | ||||||||||||||||||||||||||
| # If you develop on Mac or Windows you can remove the vendor/ directory | ||||||||||||||||||||||||||
| # from the bind-mount for better performance by enabling the next line: | ||||||||||||||||||||||||||
| - /app/vendor | ||||||||||||||||||||||||||
|
Comment on lines
+7
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
to be consistent |
||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||
| FRANKENPHP_WORKER_CONFIG: watch | ||||||||||||||||||||||||||
| MERCURE_EXTRA_DIRECTIVES: demo | ||||||||||||||||||||||||||
| # See https://xdebug.org/docs/all_settings#mode | ||||||||||||||||||||||||||
| XDEBUG_MODE: "${XDEBUG_MODE:-off}" | ||||||||||||||||||||||||||
| APP_ENV: "${APP_ENV:-dev}" | ||||||||||||||||||||||||||
| extra_hosts: | ||||||||||||||||||||||||||
| # Ensure that host.docker.internal is correctly defined on Linux | ||||||||||||||||||||||||||
| - host.docker.internal:host-gateway | ||||||||||||||||||||||||||
| tty: true | ||||||||||||||||||||||||||
| ###> symfony/mercure-bundle ### | ||||||||||||||||||||||||||
| ###< symfony/mercure-bundle ### | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Production environment override | ||
| services: | ||
| php: | ||
| build: | ||
| context: . | ||
| target: frankenphp_prod | ||
| environment: | ||
| APP_SECRET: ${APP_SECRET} | ||
| MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} | ||
| MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||||||||
| services: | ||||||||||
| php: | ||||||||||
| image: ${IMAGES_PREFIX:-}app-php | ||||||||||
| restart: unless-stopped | ||||||||||
| environment: | ||||||||||
| SERVER_NAME: ${SERVER_NAME:-localhost}, php:80 | ||||||||||
| MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} | ||||||||||
| MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} | ||||||||||
| DATABASE_URL: postgresql://${POSTGRES_USER:-symfony}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8} | ||||||||||
| MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure} | ||||||||||
| MERCURE_PUBLIC_URL: ${CADDY_MERCURE_PUBLIC_URL:-https://${SERVER_NAME:-localhost}:${HTTPS_PORT:-443}/.well-known/mercure} | ||||||||||
| MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} | ||||||||||
| # The two next lines can be removed after initial installation | ||||||||||
| SYMFONY_VERSION: ${SYMFONY_VERSION:-} | ||||||||||
| STABILITY: ${STABILITY:-stable} | ||||||||||
| volumes: | ||||||||||
| - caddy_data:/data | ||||||||||
| - caddy_config:/config | ||||||||||
|
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| ports: | ||||||||||
| - name: http | ||||||||||
| target: 80 | ||||||||||
| published: ${HTTP_PORT:-80} | ||||||||||
| protocol: tcp | ||||||||||
| - name: https | ||||||||||
| target: 443 | ||||||||||
| published: ${HTTPS_PORT:-443} | ||||||||||
| protocol: tcp | ||||||||||
| - name: http3 | ||||||||||
| target: 443 | ||||||||||
| published: ${HTTP3_PORT:-443} | ||||||||||
| protocol: udp | ||||||||||
|
|
||||||||||
| ###> doctrine/doctrine-bundle ### | ||||||||||
| database: | ||||||||||
| image: postgres:${POSTGRES_VERSION:-15}-alpine | ||||||||||
| environment: | ||||||||||
| POSTGRES_DB: ${POSTGRES_DB:-app} | ||||||||||
| # You should definitely change the password in production | ||||||||||
| POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!} | ||||||||||
| POSTGRES_USER: ${POSTGRES_USER:-symfony} | ||||||||||
| volumes: | ||||||||||
| - database_data:/var/lib/postgresql/data:rw | ||||||||||
| # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! | ||||||||||
| # - ./docker/db/data:/var/lib/postgresql/data:rw | ||||||||||
| ###< doctrine/doctrine-bundle ### | ||||||||||
|
|
||||||||||
| volumes: | ||||||||||
| caddy_data: | ||||||||||
| caddy_config: | ||||||||||
| ###> symfony/mercure-bundle ### | ||||||||||
| ###< symfony/mercure-bundle ### | ||||||||||
|
|
||||||||||
| ###> doctrine/doctrine-bundle ### | ||||||||||
| database_data: | ||||||||||
| ###< doctrine/doctrine-bundle ### | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,30 +12,31 @@ | |
| "php": ">=8.2", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's bump that as well, so we can leverage new PHP features such as property hooks. |
||
| "ext-ctype": "*", | ||
| "ext-iconv": "*", | ||
| "api-platform/core": "^3.2", | ||
| "api-platform/core": "^4.2", | ||
| "doctrine/doctrine-bundle": "^2.9", | ||
| "doctrine/orm": "^2.15", | ||
|
Comment on lines
16
to
17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We must bump it as well to support native lazy ghosts for sure (please use the latest version). |
||
| "nelmio/cors-bundle": "^2.3", | ||
| "phpdocumentor/reflection-docblock": "^5.3", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since API Platform 4, I think we don't need that anymore (thanks to |
||
| "phpstan/phpdoc-parser": "^1.2", | ||
| "symfony/asset": "7.0.*", | ||
| "symfony/console": "7.0.*", | ||
| "symfony/dotenv": "7.0.*", | ||
| "symfony/expression-language": "7.0.*", | ||
| "phpstan/phpdoc-parser": "^1.30", | ||
| "runtime/frankenphp-symfony": "^0.2.0", | ||
| "symfony/asset": "^7.2", | ||
| "symfony/console": "^7.2", | ||
| "symfony/dotenv": "^7.2", | ||
| "symfony/expression-language": "^7.2", | ||
| "symfony/flex": "^2", | ||
| "symfony/framework-bundle": "7.0.*", | ||
| "symfony/messenger": "7.0.*", | ||
| "symfony/framework-bundle": "^7.2", | ||
| "symfony/messenger": "^7.2", | ||
| "symfony/monolog-bundle": "^3.8", | ||
| "symfony/property-access": "7.0.*", | ||
| "symfony/property-info": "7.0.*", | ||
| "symfony/runtime": "7.0.*", | ||
| "symfony/security-bundle": "7.0.*", | ||
| "symfony/serializer": "7.0.*", | ||
| "symfony/string": "*", | ||
| "symfony/twig-bundle": "7.0.*", | ||
| "symfony/uid": "7.0.*", | ||
| "symfony/validator": "7.0.*", | ||
| "symfony/yaml": "7.0.*", | ||
| "symfony/property-access": "^7.2", | ||
| "symfony/property-info": "^7.2", | ||
| "symfony/runtime": "^7.2", | ||
| "symfony/security-bundle": "^7.2", | ||
| "symfony/serializer": "^7.2", | ||
| "symfony/string": "^7.2", | ||
| "symfony/twig-bundle": "^7.2", | ||
| "symfony/uid": "^7.2", | ||
| "symfony/validator": "^7.2", | ||
| "symfony/yaml": "^7.2", | ||
| "webmozart/assert": "^1.11" | ||
| }, | ||
| "config": { | ||
|
|
@@ -86,7 +87,7 @@ | |
| "extra": { | ||
| "symfony": { | ||
| "allow-contrib": false, | ||
| "require": "7.0.*", | ||
| "require": "^7.2", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can go for 7.3! And soon to 7.4 😉 |
||
| "docker": true | ||
| } | ||
| }, | ||
|
|
@@ -95,13 +96,13 @@ | |
| "justinrainbow/json-schema": "^5.2", | ||
| "phpunit/phpunit": "^9.6", | ||
| "qossmic/deptrac-shim": "^1.0", | ||
| "symfony/browser-kit": "7.0.*", | ||
| "symfony/css-selector": "7.0.*", | ||
| "symfony/debug-bundle": "7.0.*", | ||
| "symfony/http-client": "7.0.*", | ||
| "symfony/phpunit-bridge": "7.0.*", | ||
| "symfony/stopwatch": "7.0.*", | ||
| "symfony/web-profiler-bundle": "7.0.*", | ||
| "vimeo/psalm": "^5.12" | ||
| "symfony/browser-kit": "^7.2", | ||
| "symfony/css-selector": "^7.2", | ||
| "symfony/debug-bundle": "^7.2", | ||
| "symfony/http-client": "^7.2", | ||
| "symfony/phpunit-bridge": "^7.2", | ||
| "symfony/stopwatch": "^7.2", | ||
| "symfony/web-profiler-bundle": "^7.2", | ||
| "vimeo/psalm": "^6.13" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking of switching to PHPStan. But it's for another PR |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update these as well.