feat: Docker Compose — app, PostgreSQL 17, опциональный Caddy
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+58
-7
@@ -1,22 +1,73 @@
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17
|
||||
image: postgres:17-alpine
|
||||
container_name: shop-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: shop
|
||||
POSTGRES_PASSWORD: shop
|
||||
POSTGRES_DB: shop
|
||||
ports:
|
||||
- '5432:5432'
|
||||
POSTGRES_USER: ${POSTGRES_USER:-shop}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-shop}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-shop}
|
||||
volumes:
|
||||
- shop_pg_data:/var/lib/postgresql/data
|
||||
- ./postgres/init:/docker-entrypoint-initdb.d:ro
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U shop -d shop']
|
||||
test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
networks:
|
||||
- shop
|
||||
|
||||
app:
|
||||
build: .
|
||||
container_name: shop-app
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
HOST: 0.0.0.0
|
||||
PORT: 3000
|
||||
TRUST_PROXY: ${TRUST_PROXY:-0}
|
||||
SESSION_SECRET: ${SESSION_SECRET:-change-me-in-docker-compose-env}
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-shop}:${POSTGRES_PASSWORD:-shop}@postgres:5432/${POSTGRES_DB:-shop}
|
||||
ports:
|
||||
- '${APP_PORT:-3000}:3000'
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://127.0.0.1:3000/health']
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 15s
|
||||
networks:
|
||||
- shop
|
||||
|
||||
caddy:
|
||||
image: caddy:2-alpine
|
||||
container_name: shop-caddy
|
||||
profiles:
|
||||
- proxy
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
app:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- '80:80'
|
||||
- '443:443'
|
||||
volumes:
|
||||
- ./caddy/Caddyfile.docker.example:/etc/caddy/Caddyfile:ro
|
||||
- caddy_data:/data
|
||||
- caddy_config:/config
|
||||
networks:
|
||||
- shop
|
||||
|
||||
networks:
|
||||
shop:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
shop_pg_data:
|
||||
caddy_data:
|
||||
caddy_config:
|
||||
|
||||
Reference in New Issue
Block a user