feat: add Docker Compose environment with Caddy, PostgreSQL 17, Redis, PHP-FPM workers

This commit is contained in:
Simon Kuehn 2026-05-14 04:14:55 +00:00
commit 2a47979e34
7 changed files with 181 additions and 0 deletions

15
.env Normal file
View file

@ -0,0 +1,15 @@
APP_ENV=prod
APP_SECRET=change_me_in_env_local
POSTGRES_DB=superseller
POSTGRES_USER=superseller
POSTGRES_PASSWORD=change_me
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?serverVersion=17&charset=utf8"
REDIS_PASSWORD=change_me
REDIS_URL=redis://:${REDIS_PASSWORD}@redis:6379
MESSENGER_TRANSPORT_DSN=redis://:${REDIS_PASSWORD}@redis:6379/messages
MAILER_DSN=smtp://localhost
OLLAMA_URL=http://localhost:11434

7
.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
/.env.local
/.env.*.local
/vendor/
/var/
/public/bundles/
/.php-cs-fixer.cache
/.phpunit.result.cache

View file

@ -0,0 +1,13 @@
services:
caddy:
ports:
- "80:80"
- "443:443"
postgres:
ports:
- "5432:5432"
redis:
ports:
- "6379:6379"

104
docker-compose.yml Normal file
View file

@ -0,0 +1,104 @@
services:
app:
build:
context: .
dockerfile: docker/app/Dockerfile
volumes:
- .:/var/www
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
env_file: .env
caddy:
image: caddy:2-alpine
volumes:
- ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile
- .:/var/www
- caddy_data:/data
depends_on:
- app
postgres:
image: postgres:17-alpine
env_file: .env
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
command: redis-server --requirepass ${REDIS_PASSWORD}
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 5s
timeout: 5s
retries: 5
worker-ai:
build:
context: .
dockerfile: docker/app/Dockerfile
command: php bin/console messenger:consume ai_pipeline --time-limit=3600 --memory-limit=256M
volumes:
- .:/var/www
depends_on:
- postgres
- redis
env_file: .env
restart: unless-stopped
worker-orders:
build:
context: .
dockerfile: docker/app/Dockerfile
command: php bin/console messenger:consume orders --time-limit=3600 --memory-limit=256M
volumes:
- .:/var/www
depends_on:
- postgres
- redis
env_file: .env
restart: unless-stopped
worker-channel:
build:
context: .
dockerfile: docker/app/Dockerfile
command: php bin/console messenger:consume channel_sync --time-limit=3600 --memory-limit=256M
volumes:
- .:/var/www
depends_on:
- postgres
- redis
env_file: .env
restart: unless-stopped
cron:
build:
context: .
dockerfile: docker/app/Dockerfile
command: >
sh -c "while true; do
php bin/console app:logs:rotate;
sleep 86400;
done"
volumes:
- .:/var/www
depends_on:
- postgres
env_file: .env
restart: unless-stopped
volumes:
postgres_data:
redis_data:
caddy_data:

19
docker/app/Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM php:8.4-fpm-alpine
RUN apk add --no-cache \
postgresql-dev \
icu-dev \
libzip-dev \
unzip \
git \
&& docker-php-ext-install \
pdo_pgsql \
intl \
zip \
opcache
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
COPY docker/app/php.ini /usr/local/etc/php/conf.d/app.ini

7
docker/app/php.ini Normal file
View file

@ -0,0 +1,7 @@
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
memory_limit=256M
upload_max_filesize=20M
post_max_size=20M

16
docker/caddy/Caddyfile Normal file
View file

@ -0,0 +1,16 @@
{
admin off
}
:80 {
root * /var/www/public
php_fastcgi app:9000
file_server
encode gzip
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
}
}