onbekende flag 2

This commit is contained in:
Frank
2026-01-11 15:25:03 +01:00
parent b649d48250
commit badca1af53
8 changed files with 162 additions and 200 deletions

View File

@@ -1,7 +1,27 @@
version: '3.7'
services: services:
php:
environment:
XDEBUG_MODE: off
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- mailer
###> symfony/mercure-bundle ### ###> symfony/mercure-bundle ###
mercure: mercure:
ports: ports:
- "80" - "80"
###< symfony/mercure-bundle ### ###< symfony/mercure-bundle ###
###> symfony/mailer ###
mailer:
image: axllent/mailpit
ports:
- "1025:1025"
- "8025:8025"
environment:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
###< symfony/mailer ###

View File

@@ -1,31 +1,133 @@
version: '3.7'
services: services:
###> symfony/mercure-bundle ### php:
mercure: build:
image: dunglas/mercure context: .
restart: unless-stopped dockerfile: docker/php/Dockerfile
args:
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
container_name: escapepage-php
volumes:
- ./:/var/www/html:delegated
- /etc/hosts:/etc/hosts:ro
environment: environment:
# Uncomment the following line to disable HTTPS, APP_ENV: ${APP_ENV:-dev}
#SERVER_NAME: ':80' depends_on:
- database
- mercure
networks:
backend:
ipv4_address: 172.20.0.10
restart: unless-stopped
php-worker:
build:
context: .
dockerfile: docker/php/Dockerfile
args:
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
container_name: escapepage-php-worker
volumes:
- ./:/var/www/html:delegated
- /etc/hosts:/etc/hosts:ro
environment:
APP_ENV: ${APP_ENV:-dev}
depends_on:
- database
- mercure
command: ["php", "bin/console", "messenger:consume", "async", "-vv"]
networks:
backend:
ipv4_address: 172.20.0.11
restart: unless-stopped
nginx:
image: nginx:1.29.4-alpine
container_name: escapepage-nginx
ports:
- "8080:80"
- "8443:443"
volumes:
- ./:/var/www/html:ro
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
- ./docker/nginx/ssl:/etc/nginx/ssl:ro
- /etc/hosts:/etc/hosts:ro
depends_on:
- php
networks:
backend:
ipv4_address: 172.20.0.12
restart: unless-stopped
mailer:
image: axllent/mailpit:latest
container_name: escapepage-mailer
ports:
- "8025:8025"
volumes:
- /etc/hosts:/etc/hosts:ro
networks:
backend:
ipv4_address: 172.20.0.13
restart: unless-stopped
mercure:
image: dunglas/mercure:v0.21
container_name: escapepage-mercure
environment:
SERVER_NAME: ":80"
MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_JWT_SECRET} MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_JWT_SECRET}
MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_JWT_SECRET} MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_JWT_SECRET}
# Set the URL of your Symfony project (without trailing slash!) as value of the cors_origins directive MERCURE_CORS_ALLOWED_ORIGINS: ${MERCURE_CORS_ALLOWED_ORIGINS:-http://localhost:8080}
MERCURE_PUBLISH_ALLOWED_ORIGINS: ${MERCURE_CORS_ALLOWED_ORIGINS:-http://localhost:8080}
MERCURE_EXTRA_DIRECTIVES: | MERCURE_EXTRA_DIRECTIVES: |
cors_origins ${MERCURE_CORS_ALLOWED_ORIGINS:-http://localhost:8080} cors_origins ${MERCURE_CORS_ALLOWED_ORIGINS:-http://localhost:8080}
# Comment the following line to disable the development mode # Allow anonymous subscribers in dev only
command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile anonymous
healthcheck: ports:
test: ["CMD", "curl", "-f", "https://localhost/healthz"] - "8090:80"
timeout: 5s
retries: 5
start_period: 60s
volumes: volumes:
- mercure_data:/data - /etc/hosts:/etc/hosts:ro
- mercure_config:/config networks:
###< symfony/mercure-bundle ### backend:
ipv4_address: 172.20.0.14
restart: unless-stopped
volumes: ###> doctrine/doctrine-bundle ###
###> symfony/mercure-bundle ### database:
mercure_data: image: mysql:8.0
mercure_config: container_name: escapepage-db
###< symfony/mercure-bundle ### environment:
MYSQL_DATABASE: ${DB_NAME:-app}
MYSQL_USER: ${DB_USER:-app}
MYSQL_PASSWORD: ${DB_PASSWORD:-!ChangeMe!}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-p${MYSQL_ROOT_PASSWORD:-root}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
command: ["--default-authentication-plugin=mysql_native_password", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
volumes:
- ./var/volumes/db:/var/lib/mysql:rw
- ./docker/mysql/init:/docker-entrypoint-initdb.d:ro
- /etc/hosts:/etc/hosts:ro
# Uncomment the two lines below if you need to access MySQL from your host (workbench, etc.)
ports:
- "3306:3306"
networks:
backend:
ipv4_address: 172.20.0.15
restart: unless-stopped
###< doctrine/doctrine-bundle ###
networks:
backend:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16

View File

@@ -3,8 +3,8 @@
Use this index to quickly locate files and directories during development and in discussions. Use this index to quickly locate files and directories during development and in discussions.
## Top-Level ## Top-Level
- docker/compose.yaml / docker/compose.override.yaml — Docker services. - compose.yaml / compose.override.yaml — Docker services.
- docker/ — Docker build contexts and configs (php Dockerfile, nginx vhost, compose files). - docker/ — Docker build contexts and configs (php Dockerfile, nginx vhost).
- composer.json / composer.lock — Dependencies and scripts. - composer.json / composer.lock — Dependencies and scripts.
- importmap.php — Importmap configuration for JS dependencies. - importmap.php — Importmap configuration for JS dependencies.
- phpunit.dist.xml — PHPUnit configuration. - phpunit.dist.xml — PHPUnit configuration.

View File

@@ -21,36 +21,36 @@ App will be served at http://localhost:8080
Alternatively (manual): Alternatively (manual):
``` ```
docker compose -f docker/compose.yaml -f docker/compose.override.yaml up -d --build docker compose up -d --build
``` ```
### 2) Install dependencies ### 2) Install dependencies
The setup script already runs composer install. To run manually: The setup script already runs composer install. To run manually:
``` ```
docker compose -f docker/compose.yaml -f docker/compose.override.yaml exec php composer install docker compose exec php composer install
``` ```
### 3) Prepare DB ### 3) Prepare DB
The setup script already prepares the DB. To run manually: The setup script already prepares the DB. To run manually:
``` ```
docker compose -f docker/compose.yaml -f docker/compose.override.yaml exec php php bin/console doctrine:database:create --if-not-exists docker compose exec php php bin/console doctrine:database:create --if-not-exists
docker compose -f docker/compose.yaml -f docker/compose.override.yaml exec php php bin/console doctrine:migrations:migrate -n docker compose exec php php bin/console doctrine:migrations:migrate -n
``` ```
### 4) Run tests ### 4) Run tests
``` ```
docker compose -f docker/compose.yaml -f docker/compose.override.yaml exec php vendor/bin/phpunit docker compose exec php vendor/bin/phpunit
``` ```
### 5) Logs ### 5) Logs
``` ```
docker compose -f docker/compose.yaml -f docker/compose.override.yaml logs -f nginx docker compose logs -f nginx
docker compose -f docker/compose.yaml -f docker/compose.override.yaml logs -f php docker compose logs -f php
``` ```
### 6) Stop ### 6) Stop
``` ```
docker compose -f docker/compose.yaml -f docker/compose.override.yaml down docker compose down
``` ```
## Notes ## Notes

View File

@@ -1,23 +0,0 @@
services:
php:
environment:
XDEBUG_MODE: off
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- mailer
###> doctrine/doctrine-bundle ###
###< doctrine/doctrine-bundle ###
###> symfony/mailer ###
mailer:
image: axllent/mailpit
ports:
- "1025:1025"
- "8025:8025"
environment:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
###< symfony/mailer ###

View File

@@ -1,137 +0,0 @@
version: '3.7'
services:
php:
build:
context: ..
dockerfile: docker/php/Dockerfile
args:
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
container_name: escapepage-php
volumes:
- ../:/var/www/html:delegated
- /etc/hosts:/etc/hosts:ro
environment:
APP_ENV: ${APP_ENV:-dev}
depends_on:
- database
- mercure
networks:
backend:
ipv4_address: 172.20.0.10
restart: unless-stopped
php-worker:
build:
context: ..
dockerfile: docker/php/Dockerfile
args:
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
container_name: escapepage-php-worker
volumes:
- ../:/var/www/html:delegated
- /etc/hosts:/etc/hosts:ro
environment:
APP_ENV: ${APP_ENV:-dev}
depends_on:
- database
- mercure
command: ["php", "bin/console", "messenger:consume", "async", "-vv"]
networks:
backend:
ipv4_address: 172.20.0.11
restart: unless-stopped
nginx:
image: nginx:1.29.4-alpine
container_name: escapepage-nginx
ports:
- "8080:80"
- "8443:443"
volumes:
- ../:/var/www/html:ro
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- /etc/hosts:/etc/hosts:ro
depends_on:
- php
networks:
backend:
ipv4_address: 172.20.0.12
restart: unless-stopped
mailer:
image: axllent/mailpit:latest
container_name: escapepage-mailer
ports:
- "8025:8025"
volumes:
- /etc/hosts:/etc/hosts:ro
networks:
backend:
ipv4_address: 172.20.0.13
restart: unless-stopped
mercure:
image: dunglas/mercure:v0.21
container_name: escapepage-mercure
environment:
SERVER_NAME: ":80"
MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_JWT_SECRET}
MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_JWT_SECRET}
MERCURE_CORS_ALLOWED_ORIGINS: ${MERCURE_CORS_ALLOWED_ORIGINS:-http://localhost:8080}
MERCURE_PUBLISH_ALLOWED_ORIGINS: ${MERCURE_CORS_ALLOWED_ORIGINS:-http://localhost:8080}
MERCURE_EXTRA_DIRECTIVES: |
cors_origins ${MERCURE_CORS_ALLOWED_ORIGINS:-http://localhost:8080}
# Allow anonymous subscribers in dev only
anonymous
ports:
- "8090:80"
volumes:
- /etc/hosts:/etc/hosts:ro
networks:
backend:
ipv4_address: 172.20.0.14
restart: unless-stopped
###> doctrine/doctrine-bundle ###
database:
image: mysql:8.0
container_name: escapepage-db
environment:
MYSQL_DATABASE: ${DB_NAME:-app}
MYSQL_USER: ${DB_USER:-app}
MYSQL_PASSWORD: ${DB_PASSWORD:-!ChangeMe!}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-p${MYSQL_ROOT_PASSWORD:-root}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
command: ["--default-authentication-plugin=mysql_native_password", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
volumes:
- ../var/volumes/db:/var/lib/mysql:rw
- ./mysql/init:/docker-entrypoint-initdb.d:ro
- /etc/hosts:/etc/hosts:ro
# Uncomment the two lines below if you need to access MySQL from your host (workbench, etc.)
ports:
- "3306:3306"
networks:
backend:
ipv4_address: 172.20.0.15
restart: unless-stopped
###< doctrine/doctrine-bundle ###
###> doctrine/doctrine-bundle ###
###< doctrine/doctrine-bundle ###
networks:
backend:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16

View File

@@ -4,7 +4,7 @@ set -euo pipefail
# Script to completely restart the project as requested # Script to completely restart the project as requested
echo "Stopping and removing containers..." echo "Stopping and removing containers..."
dc() { (cd "$(dirname "$0")/.." && docker compose -f docker/compose.yaml "$@"); } dc() { (cd "$(dirname "$0")/.." && docker compose "$@"); }
dc down --remove-orphans dc down --remove-orphans
echo "Clearing Docker build cache..." echo "Clearing Docker build cache..."

View File

@@ -28,7 +28,7 @@ else
fi fi
# Helper to run docker compose from the project root # Helper to run docker compose from the project root
dc() { (cd "$ROOT_DIR" && $DOCKER_COMPOSE -f docker/compose.yaml "$@"); } dc() { (cd "$ROOT_DIR" && $DOCKER_COMPOSE "$@"); }
REBUILD=1 REBUILD=1
RECREATE=0 RECREATE=0
@@ -132,12 +132,12 @@ Open the app: $APP_URL
Mailpit (dev): $MAILPIT_URL Mailpit (dev): $MAILPIT_URL
Common commands: Common commands:
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f nginx) (cd "$ROOT_DIR" && $DOCKER_COMPOSE logs -f nginx)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f php) (cd "$ROOT_DIR" && $DOCKER_COMPOSE logs -f php)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f php-worker) (cd "$ROOT_DIR" && $DOCKER_COMPOSE logs -f php-worker)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE exec php bash) (cd "$ROOT_DIR" && $DOCKER_COMPOSE exec php bash)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE exec php npm run watch) (cd "$ROOT_DIR" && $DOCKER_COMPOSE exec php npm run watch)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE down) (cd "$ROOT_DIR" && $DOCKER_COMPOSE down)
You can re-run this script any time. Use --no-build to skip rebuilding images. You can re-run this script any time. Use --no-build to skip rebuilding images.
EOT EOT