Skip to content

Project #821

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@

VOLUME /app/var/

RUN apt-get update && apt-get install -y tzdata

Check failure on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3015 info: Avoid additional packages by specifying `--no-install-recommends`

Check failure on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3009 info: Delete the apt-get lists after installing something

Check failure on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
RUN date # Vérifie l'heure

RUN apt-get update && apt-get install -y \

Check failure on line 21 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3009 info: Delete the apt-get lists after installing something

Check failure on line 21 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3015 info: Avoid additional packages by specifying `--no-install-recommends`

Check failure on line 21 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker Lint

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
docker.io \
curl \
&& apt-get clean
# persistent / runtime deps
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends \
acl \
file \
gettext \
git \
npm \
&& rm -rf /var/lib/apt/lists/*

RUN set -eux; \
Expand All @@ -31,6 +39,8 @@
intl \
opcache \
zip \
gd \
mbstring \
;

# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
Expand All @@ -42,11 +52,18 @@
ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d"

###> recipes ###
###> doctrine/doctrine-bundle ###
RUN install-php-extensions pdo_mysql
###< doctrine/doctrine-bundle ###
###< 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/frankenphp/Caddyfile
COPY ../certs/localhost.crt /etc/ssl/certs/localhost.crt
COPY ../certs/localhost.key /etc/ssl/private/localhost.key


COPY --link docker/frankenphp/conf.d/10-app.ini $PHP_INI_DIR/app.conf.d/
COPY --link --chmod=755 docker/frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY --link docker/frankenphp/Caddyfile /etc/frankenphp/Caddyfile

ENTRYPOINT ["docker-entrypoint"]

Expand All @@ -67,7 +84,7 @@
xdebug \
;

COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/
COPY --link docker/frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/

CMD [ "frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile", "--watch" ]

Expand All @@ -78,20 +95,21 @@

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 docker/frankenphp/conf.d/20-app.prod.ini $PHP_INI_DIR/app.conf.d/

# prevent the reinstallation of vendors at every changes in the source code
COPY --link composer.* symfony.* ./
COPY --link ../sulu/composer.* ../sulu/symfony.* ./
RUN set -eux; \
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
COMPOSER_MEMORY_LIMIT=-1 composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress

# copy sources
COPY --link . ./
COPY --link ../sulu ./
RUN rm -Rf frankenphp/

RUN set -eux; \
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; sync;
mkdir -p var/cache var/log; \
COMPOSER_MEMORY_LIMIT=-1 composer dump-autoload --classmap-authoritative --no-dev; \
COMPOSER_MEMORY_LIMIT=-1 composer dump-env prod; \
COMPOSER_MEMORY_LIMIT=-1 composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; sync; \
chown -R www-data:www-data var vendor
8 changes: 6 additions & 2 deletions compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
services:
php:
build:
context: .
context: ..
dockerfile: docker/Dockerfile
target: frankenphp_dev
volumes:
- ./:/app
- ../sulu:/app
- ./frankenphp/Caddyfile:/etc/frankenphp/Caddyfile:ro
- ./frankenphp/conf.d/20-app.dev.ini:/usr/local/etc/php/app.conf.d/20-app.dev.ini:ro
- ../certs:/etc/caddy/certs: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
environment:
CADDY_SERVER_EXTRA_DIRECTIVES: "tls /etc/caddy/certs/localhost.pem /etc/caddy/certs/localhost-key.pem"
CADDY_GLOBAL_OPTIONS: "auto_https disable_certs"
FRANKENPHP_WORKER_CONFIG: watch
MERCURE_EXTRA_DIRECTIVES: demo
# See https://xdebug.org/docs/all_settings#mode
Expand Down
18 changes: 15 additions & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
services:
php:
build:
context: ..
dockerfile: docker/Dockerfile
image: ${IMAGES_PREFIX:-}app-php
restart: unless-stopped
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80
SERVER_NAME: ${SERVER_NAME:-localhost}, php:443
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-15}&charset=${POSTGRES_CHARSET:-utf8}
DATABASE_URL: mysql://${MYSQL_USER:-guillaume}:${MYSQL_PASSWORD:-my-secret-pw}@192.168.1.201:3306/${MYSQL_DATABASE:-sulu}?serverVersion=${MYSQL_VERSION:-8}&charset=${MYSQL_CHARSET:-utf8mb4}
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
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}
Expand All @@ -16,8 +20,12 @@ services:
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
STABILITY: ${STABILITY:-stable}
volumes:
- ../sulu:/app # Montage du code Symfony dans /app
- ../sulu/var:/app/var
- caddy_data:/data
- caddy_config:/config
- ../docker-permanently/php/uploads/media:/app/var/uploads/media:rwo
- /var/run/docker.sock:/var/run/docker.sock
ports:
# HTTP
- target: 80
Expand All @@ -31,7 +39,11 @@ services:
- target: 443
published: ${HTTP3_PORT:-443}
protocol: udp

deploy:
resources:
limits:
memory: 20G
cpus: '4.0'
# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###
Expand Down
10 changes: 2 additions & 8 deletions frankenphp/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@

frankenphp {
{$FRANKENPHP_CONFIG}

worker {
file ./public/index.php
env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime
{$FRANKENPHP_WORKER_CONFIG}
}
}
}

{$CADDY_EXTRA_CONFIG}

{$SERVER_NAME:localhost} {
{$CADDY_EXTRA_CONFIG}

log {
{$CADDY_SERVER_LOG_OPTIONS}
# Redact the authorization query parameter that can be set by Mercure
Expand Down
1 change: 1 addition & 0 deletions frankenphp/conf.d/10-app.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
opcache.enable_file_override = 1
memory.limit = -1
10 changes: 8 additions & 2 deletions frankenphp/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
echo 'To finish the installation please press Ctrl+C to stop Docker Compose and run: docker compose up --build --wait'
sleep infinity
fi
else
COMPOSER_MEMORY_LIMIT=-1 composer require "php:>=$PHP_VERSION" symfony/runtime runtime/frankenphp-symfony
COMPOSER_MEMORY_LIMIT=-1 composer config --json extra.symfony.docker 'true'
fi

if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then
Expand Down Expand Up @@ -57,8 +60,11 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
fi
fi

setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var
# Ensure writable directories are owned by the web server user
chown -R www-data:www-data var vendor 2>/dev/null || true

setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var vendor composer.lock
setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var vendor composer.lock

echo 'PHP app ready!'
fi
Expand Down
Loading