services:
  strapi:
    build:
      context: .
      dockerfile: Dockerfile
      target: production
    image: malpani-group-cms:latest
    container_name: malpani-group-cms
    restart: unless-stopped
    env_file: .env
    environment:
      NODE_ENV: production
      DATABASE_CLIENT: sqlite
      DATABASE_FILENAME: .tmp/data.db
    ports:
      - "${PORT:-9003}:9003"
    volumes:
      # Mount database and uploads as volumes to persist data across container rebuilds
      - ./public/uploads:/app/public/uploads
      - ./.tmp:/app/.tmp
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://0.0.0.0:9003/_health"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 90s
    networks:
      - strapi-network
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "5"
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2G
        reservations:
          cpus: '0.5'
          memory: 512M

networks:
  strapi-network:
    driver: bridge
