version: '3.8'

services:
  app:
    build: .
    image: nextgen-school:latest
    ports:
      - "3001:3001"
    environment:
      NODE_ENV: production
      PORT: 3001
      DB_PATH: /app/data/school.db
      JWT_SECRET: ${JWT_SECRET:-africa-alert-production-secret-2024}
      ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-https://next-gen.techarvest.co.zw,http://localhost:3001}
      ALLOW_CLIENT_OFFLINE_MINT: ${ALLOW_CLIENT_OFFLINE_MINT:-false}
    env_file:
      - path: .env
        required: false
    volumes:
      - ./data:/app/data
      - ./uploads:/app/server/uploads
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3001/api/health',r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 15s
