Files
ai-stylegallery/docker-compose.yml
2025-12-05 19:38:25 +01:00

143 lines
3.5 KiB
YAML

version: "3.9"
networks:
backend:
traefik:
external: true
volumes:
mysql_data:
redis_data:
storage_data:
bootstrap_cache:
services:
app:
build:
context: .
target: php_app
image: stylegallery-app:latest
env_file:
- .env.docker
restart: unless-stopped
command: >
sh -c "
chown -R www-data:www-data storage bootstrap/cache &&
php artisan package:discover --ansi &&
php artisan storage:link --ansi || true &&
php artisan config:cache --ansi &&
php artisan route:cache --ansi &&
php artisan view:cache --ansi &&
php-fpm
"
volumes:
- storage_data:/var/www/html/storage
- bootstrap_cache:/var/www/html/bootstrap/cache
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- backend
healthcheck:
test: ["CMD", "php", "-v"]
interval: 30s
timeout: 5s
retries: 3
queue:
image: stylegallery-app:latest
env_file:
- .env.docker
restart: unless-stopped
command: ["sh", "-c", "php artisan queue:work --sleep=3 --tries=3 --max-time=3600"]
volumes:
- storage_data:/var/www/html/storage
- bootstrap_cache:/var/www/html/bootstrap/cache
depends_on:
app:
condition: service_started
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- backend
scheduler:
image: stylegallery-app:latest
env_file:
- .env.docker
restart: unless-stopped
command: ["sh", "-c", "php artisan schedule:work"]
volumes:
- storage_data:/var/www/html/storage
- bootstrap_cache:/var/www/html/bootstrap/cache
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- backend
nginx:
build:
context: .
target: nginx
image: stylegallery-nginx:latest
restart: unless-stopped
depends_on:
app:
condition: service_started
networks:
- backend
- traefik
volumes:
- storage_data:/var/www/html/storage:ro
- bootstrap_cache:/var/www/html/bootstrap/cache:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.stylegallery.rule=Host(`stylegallery.fotospiel.app`)"
- "traefik.http.routers.stylegallery.entrypoints=websecure"
- "traefik.http.routers.stylegallery.tls=true"
- "traefik.http.services.stylegallery.loadbalancer.server.port=80"
mysql:
image: mysql:8.0
env_file:
- .env.docker
restart: unless-stopped
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
command: ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
volumes:
- mysql_data:/var/lib/mysql
networks:
- backend
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h localhost -p${DB_PASSWORD}"]
interval: 30s
timeout: 10s
retries: 5
redis:
image: redis:7-alpine
env_file:
- .env.docker
restart: unless-stopped
command: ["sh", "-c", "exec redis-server --appendonly yes --requirepass \"$REDIS_PASSWORD\""]
volumes:
- redis_data:/data
networks:
- backend
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 30s
timeout: 5s
retries: 3