# GnommoEditor — Production
# Usage: ./deploy.sh  (local)  or  bash start.sh  (on the server)
# The `gnommo` network is created automatically by start.sh if it doesn't exist.
# gu_common must be running to provide gnommo-db (postgres) and gnommo-minio.

services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: gnommoeditor-backend
    restart: unless-stopped
    environment:
      NODE_ENV: production
      PORT: 3001
      DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@gnommo-db:5432/${POSTGRES_DB}
      INGEST_API_KEY: ${INGEST_API_KEY}
      JWT_SECRET: ${JWT_SECRET}
      CORS_ORIGIN: https://${EDITOR_DOMAIN}
      MINIO_ENDPOINT: http://gnommo-minio:9000
      MINIO_PUBLIC_URL: https://glitch.university/media
      MINIO_BUCKET: glitch-university
      MINIO_ROOT_USER: ${MINIO_ROOT_USER}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
    expose:
      - "3001"
    networks:
      - default
      - gnommo

  frontend:
    build:
      context: .
      dockerfile: Dockerfile.frontend
      args:
        VITE_GNOMMOWEB_URL: ${VITE_GNOMMOWEB_URL}
    container_name: gnommoeditor-frontend
    restart: unless-stopped
    expose:
      - "80"
    depends_on:
      - backend
    networks:
      - default
      - gnommo

networks:
  default: {}
  gnommo:
    external: true
