version: '3.8' services: # База данных PostgreSQL postgres: image: postgres:14-alpine container_name: sno_postgres env_file: - .env.db environment: POSTGRES_USER: ${POSTGRES_USER:-user} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password} POSTGRES_DB: ${POSTGRES_DB:-quiz_app} ports: - "${POSTGRES_PORT:-5432}:5432" volumes: - postgres_data:/var/lib/postgresql/data networks: - sno_network restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-user} -d ${POSTGRES_DB:-quiz_app}"] interval: 10s timeout: 5s retries: 5 # Migration runner migrations: build: context: ./backend dockerfile: Dockerfile container_name: sno_migrations env_file: - .env.db - .env.backend environment: - DATABASE_URL=postgres://${POSTGRES_USER:-user}:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-quiz_app}?sslmode=disable depends_on: postgres: condition: service_healthy networks: - sno_network command: > sh -c " echo 'Running database migrations...' goose -dir ./migrations postgres \"$$DATABASE_URL\" up echo 'Running setup admin script...' psql \"$$DATABASE_URL\" < /app/setup_admin.sql echo 'Migrations completed successfully' " volumes: - ./setup_admin.sql:/app/setup_admin.sql:ro profiles: - migrations # Redis для кэширования redis: image: redis:7-alpine container_name: sno_redis env_file: - .env.redis ports: - "${REDIS_PORT:-6379}:6379" volumes: - redis_data:/data networks: - sno_network restart: unless-stopped healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 3s retries: 3 # Backend на Go backend: build: context: ./backend dockerfile: Dockerfile container_name: sno_backend env_file: - ./backend/.env - .env.backend environment: - DATABASE_URL=postgres://${POSTGRES_USER:-user}:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-quiz_app}?sslmode=disable - REDIS_URL=redis://redis:6379/0 ports: - "8080:8080" depends_on: postgres: condition: service_healthy redis: condition: service_healthy networks: - sno_network restart: unless-stopped # Telegram бот на Python bot: build: context: ./bot dockerfile: Dockerfile container_name: sno_bot env_file: - ./bot/.env - .env.bot environment: - DATABASE_URL=postgres://${POSTGRES_USER:-user}:${POSTGRES_PASSWORD:-password}@postgres:5432/${POSTGRES_DB:-quiz_app}?sslmode=disable - REDIS_URL=redis://redis:6379/0 - BACKEND_API_URL=http://backend:8080 depends_on: postgres: condition: service_healthy redis: condition: service_healthy networks: - sno_network restart: unless-stopped volumes: - ./bot:/app working_dir: /app # Frontend на React (production build) frontend: build: context: ./frontend dockerfile: Dockerfile container_name: sno_frontend environment: - VITE_API_BASE_URL=http://localhost/api ports: - "${NGINX_PORT:-80}:80" depends_on: - backend networks: - sno_network restart: unless-stopped volumes: postgres_data: redis_data: networks: sno_network: driver: bridge