Files
toir-light/docker-compose.yml
Первов Артем c4e5962912 Update healthcheck configuration in docker-compose.yml for improved reliability
- Changed healthcheck command to use 'http' module for better error handling.
- Increased timeout to 10s, retries to 8, and start period to 120s to accommodate cold starts.
2026-04-21 00:52:36 +03:00

122 lines
3.4 KiB
YAML

services:
postgres:
image: postgres:16
container_name: toir-light-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me}
POSTGRES_DB: ${POSTGRES_DB:-toir}
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-toir}",
]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- toir-light
server:
build:
context: ./server
dockerfile: Dockerfile
container_name: toir-light-server
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
PORT: 3000
DATABASE_URL: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-change-me}@postgres:5432/${POSTGRES_DB:-toir}
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS:-http://localhost:8080,https://toir.greact.ru}
KEYCLOAK_ISSUER_URL: ${KEYCLOAK_ISSUER_URL:-https://sso.greact.ru/realms/toir}
KEYCLOAK_AUDIENCE: ${KEYCLOAK_AUDIENCE:-toir-backend}
KEYCLOAK_JWKS_URL: ${KEYCLOAK_JWKS_URL:-}
S3_ENDPOINT: ${S3_ENDPOINT:-}
S3_REGION: ${S3_REGION:-eu-central-1}
S3_BUCKET: ${S3_BUCKET:-media}
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-}
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-}
S3_FORCE_PATH_STYLE: ${S3_FORCE_PATH_STYLE:-true}
S3_PUBLIC_BASE_URL: ${S3_PUBLIC_BASE_URL:-}
S3_OBJECT_PREFIX: ${S3_OBJECT_PREFIX:-toir-light/equipment}
# migrate deploy runs before the HTTP server listens; cold start can exceed 20s.
healthcheck:
test:
[
"CMD",
"node",
"-e",
"require('http').get('http://127.0.0.1:3000/health',(r)=>process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))",
]
interval: 15s
timeout: 10s
retries: 8
start_period: 120s
expose:
- "3000"
networks:
- toir-light
- proxy
db-seed:
build:
context: .
dockerfile: db-seed/Dockerfile
container_name: toir-light-db-seed
restart: "no"
depends_on:
postgres:
condition: service_healthy
environment:
PGPASSWORD: ${POSTGRES_PASSWORD:-change-me}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-toir}
networks:
- toir-light
client:
build:
context: ./client
dockerfile: Dockerfile
args:
VITE_API_URL: ${VITE_API_URL:-/api}
VITE_KEYCLOAK_URL: ${VITE_KEYCLOAK_URL:-https://sso.greact.ru}
VITE_KEYCLOAK_REALM: ${VITE_KEYCLOAK_REALM:-toir}
VITE_KEYCLOAK_CLIENT_ID: ${VITE_KEYCLOAK_CLIENT_ID:-toir-frontend}
container_name: toir-light-client
restart: unless-stopped
depends_on:
server:
condition: service_healthy
db-seed:
condition: service_completed_successfully
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/healthz >/dev/null 2>&1 || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 10s
ports:
- "${CLIENT_PORT:-8080}:80"
expose:
- "80"
networks:
- toir-light
- proxy
volumes:
postgres-data:
networks:
toir-light:
driver: bridge
proxy:
external: true