- Convert multi-file overlay approach to single docker-compose.yml - Use environment variables for dev/production differences - Remove complex network configuration conflicts - Align with framework principles: simplicity over complexity - Production config via .env.production file Benefits: - No more network subnet conflicts - Single source of truth - Framework-compliant architecture - Easier maintenance and debugging Related: #19 Docker network conflict resolution
241 lines
6.4 KiB
YAML
241 lines
6.4 KiB
YAML
services:
|
|
web:
|
|
container_name: web
|
|
build:
|
|
context: docker/nginx
|
|
dockerfile: Dockerfile
|
|
ports:
|
|
- "${APP_PORT:-8000}:80"
|
|
- "127.0.0.1:8080:80"
|
|
- "${APP_SSL_PORT:-443}:443/tcp"
|
|
- "443:443/udp"
|
|
environment:
|
|
- APP_ENV=${APP_ENV:-development}
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "https://localhost/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: ${HEALTHCHECK_START_PERIOD:-10s}
|
|
logging:
|
|
driver: "${LOG_DRIVER:-local}"
|
|
options:
|
|
max-size: "${LOG_MAX_SIZE:-5m}"
|
|
max-file: "${LOG_MAX_FILE:-2}"
|
|
labels: "${LOG_LABELS:-}"
|
|
volumes:
|
|
- ./:/var/www/html:${VOLUME_MODE:-cached}
|
|
#- ./ssl:/etc/nginx/ssl:ro # SSL-Zertifikate mounten
|
|
- ./ssl:/var/www/ssl:ro
|
|
depends_on:
|
|
php:
|
|
condition: service_started
|
|
restart: ${RESTART_POLICY:-unless-stopped}
|
|
networks:
|
|
- frontend
|
|
- backend
|
|
env_file:
|
|
- .env
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: ${WEB_MEMORY_LIMIT:-256M}
|
|
cpus: ${WEB_CPU_LIMIT:-0.5}
|
|
reservations:
|
|
memory: ${WEB_MEMORY_RESERVATION:-128M}
|
|
cpus: ${WEB_CPU_RESERVATION:-0.25}
|
|
|
|
php:
|
|
container_name: php
|
|
build:
|
|
context: .
|
|
dockerfile: docker/php/Dockerfile
|
|
args:
|
|
- ENV=${APP_ENV:-dev}
|
|
- COMPOSER_INSTALL_FLAGS=${COMPOSER_INSTALL_FLAGS:---no-scripts --no-autoloader}
|
|
user: "${PHP_USER:-1000:1000}"
|
|
logging:
|
|
driver: "${LOG_DRIVER:-local}"
|
|
options:
|
|
max-size: "${LOG_MAX_SIZE:-5m}"
|
|
max-file: "${LOG_MAX_FILE:-2}"
|
|
labels: "${LOG_LABELS:-}"
|
|
volumes:
|
|
# Shared Volume für Composer-Cache über Container-Neustarts hinweg
|
|
- composer-cache:/root/.composer/cache
|
|
# Bindet das Projektverzeichnis für Produktivbetrieb ein
|
|
#- project-data:/var/www/html:cached
|
|
# Variante mit mounting:
|
|
- ./:/var/www/html:${VOLUME_MODE:-cached}
|
|
# Verhindert Überschreiben der Vendor-Verzeichnisse
|
|
#- /var/www/html/vendor
|
|
# Storage-Verzeichnisse als Docker-Volumes (keine Host-Mounts)
|
|
- storage-data:/var/www/html/storage:rw
|
|
- var-data:/var/www/html/var:rw
|
|
environment:
|
|
PHP_IDE_CONFIG: "${PHP_IDE_CONFIG:-serverName=docker}"
|
|
APP_ENV: ${APP_ENV:-development}
|
|
APP_DEBUG: ${APP_DEBUG:-true}
|
|
XDEBUG_MODE: ${XDEBUG_MODE:-debug}
|
|
healthcheck:
|
|
test: [ "CMD", "php", "-v" ]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
restart: ${RESTART_POLICY:-unless-stopped}
|
|
networks:
|
|
- backend
|
|
- cache
|
|
env_file:
|
|
- .env
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: ${PHP_MEMORY_LIMIT:-512M}
|
|
cpus: ${PHP_CPU_LIMIT:-1.0}
|
|
reservations:
|
|
memory: ${PHP_MEMORY_RESERVATION:-256M}
|
|
cpus: ${PHP_CPU_RESERVATION:-0.5}
|
|
|
|
db:
|
|
container_name: db
|
|
image: mariadb:latest
|
|
restart: ${RESTART_POLICY:-unless-stopped}
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-StartRoot2024!}
|
|
MYSQL_DATABASE: ${DB_DATABASE:-michaelschiemer}
|
|
MYSQL_USER: ${DB_USERNAME:-mdb-user}
|
|
MYSQL_PASSWORD: ${DB_PASSWORD:-StartSimple2024!}
|
|
ports:
|
|
- "${DB_PORT:-33060}:3306"
|
|
volumes:
|
|
- db_data:/var/lib/mysql
|
|
- "${DB_CONFIG_PATH:-./docker/mysql/conf.d}:/etc/mysql/conf.d:ro"
|
|
healthcheck:
|
|
test: [ "CMD", "mariadb-admin", "ping", "-h", "127.0.0.1", "-u", "root", "-p${DB_ROOT_PASSWORD:-StartRoot2024!}" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 60s
|
|
logging:
|
|
driver: "${LOG_DRIVER:-local}"
|
|
options:
|
|
max-size: "${LOG_MAX_SIZE:-5m}"
|
|
max-file: "${LOG_MAX_FILE:-2}"
|
|
labels: "${LOG_LABELS:-}"
|
|
networks:
|
|
- backend
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: ${DB_MEMORY_LIMIT:-1G}
|
|
cpus: ${DB_CPU_LIMIT:-1.0}
|
|
reservations:
|
|
memory: ${DB_MEMORY_RESERVATION:-512M}
|
|
cpus: ${DB_CPU_RESERVATION:-0.5}
|
|
|
|
redis:
|
|
container_name: redis
|
|
image: redis:7-alpine
|
|
volumes:
|
|
- "${REDIS_CONFIG_PATH:-./docker/redis/redis.conf}:/usr/local/etc/redis/redis.conf:ro"
|
|
- redis_data:/data
|
|
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 30s
|
|
restart: ${RESTART_POLICY:-unless-stopped}
|
|
logging:
|
|
driver: "${LOG_DRIVER:-local}"
|
|
options:
|
|
max-size: "${LOG_MAX_SIZE:-5m}"
|
|
max-file: "${LOG_MAX_FILE:-2}"
|
|
labels: "${LOG_LABELS:-}"
|
|
networks:
|
|
- cache
|
|
env_file:
|
|
- .env
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: ${REDIS_MEMORY_LIMIT:-256M}
|
|
cpus: ${REDIS_CPU_LIMIT:-0.5}
|
|
reservations:
|
|
memory: ${REDIS_MEMORY_RESERVATION:-128M}
|
|
cpus: ${REDIS_CPU_RESERVATION:-0.25}
|
|
|
|
queue-worker:
|
|
container_name: queue-worker
|
|
build:
|
|
context: .
|
|
dockerfile: docker/worker/Dockerfile
|
|
# user: "1000:1000" # Same user ID as PHP container
|
|
depends_on:
|
|
php:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
db:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./:/var/www/html:cached
|
|
- ./storage/logs:/var/www/html/storage/logs:rw
|
|
- ./src/Framework/CommandBus/storage:/var/www/html/src/Framework/CommandBus/storage:rw
|
|
environment:
|
|
- APP_ENV=${APP_ENV:-development}
|
|
- WORKER_DEBUG=${WORKER_DEBUG:-false}
|
|
- WORKER_SLEEP_TIME=${WORKER_SLEEP_TIME:-100000}
|
|
- WORKER_MAX_JOBS=${WORKER_MAX_JOBS:-1000}
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
- cache
|
|
env_file:
|
|
- .env
|
|
# Graceful shutdown timeout
|
|
stop_grace_period: 30s
|
|
# Resource limits for the worker
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: 512M
|
|
reservations:
|
|
memory: 256M
|
|
|
|
# websocket:
|
|
# build:
|
|
# context: .
|
|
# container_name: websocket
|
|
# command: php websocket.php
|
|
# ports:
|
|
# - "8081:8081"
|
|
# networks:
|
|
# - frontend
|
|
# - backend
|
|
# volumes:
|
|
# - ./:/var/www/html
|
|
|
|
networks:
|
|
frontend:
|
|
driver: bridge
|
|
backend:
|
|
driver: bridge
|
|
internal: ${NETWORK_BACKEND_INTERNAL:-false}
|
|
cache:
|
|
driver: bridge
|
|
internal: ${NETWORK_CACHE_INTERNAL:-false}
|
|
|
|
volumes:
|
|
redis_data:
|
|
composer-cache:
|
|
storage-data:
|
|
var-data:
|
|
#cache-volume:
|
|
db_data:
|
|
project-data:
|
|
worker-logs:
|
|
worker-queue:
|