version: '3.8'

services:
  qwen-go-mohportal:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: qwen-go-mohportal
    ports:
      - "17000:17000"
    environment:
      - PORT=17000
      - DATABASE_URL=postgresql://mohportal:password@db:5432/mohportal
      - REDIS_URL=redis:6379
      - JWT_SECRET=supersecretkeyforjwt
      - OIDC_ISSUER=https://auth.merchants-of-hope.org
      - OIDC_CLIENT_ID=mohportal-client
      - OIDC_CLIENT_SECRET=mohportal-secret
    depends_on:
      - db
      - redis
    networks:
      - mohportal-network

  db:
    image: postgres:15-alpine
    container_name: qwen-go-mohportal-db
    environment:
      - POSTGRES_DB=mohportal
      - POSTGRES_USER=mohportal
      - POSTGRES_PASSWORD=password
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    ports:
      - "5432:5432"
    networks:
      - mohportal-network

  redis:
    image: redis:7-alpine
    container_name: qwen-go-mohportal-redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - mohportal-network

  nginx:
    image: nginx:alpine
    container_name: qwen-go-mohportal-nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./ssl:/etc/nginx/ssl
    depends_on:
      - qwen-go-mohportal
    networks:
      - mohportal-network

  keycloak:
    image: quay.io/keycloak/keycloak:latest
    container_name: qwen-go-keycloak
    environment:
      - KC_DB=postgres
      - KC_DB_URL=jdbc:postgresql://db:5432/mohportal
      - KC_DB_USERNAME=mohportal
      - KC_DB_PASSWORD=password
      - KC_ADMIN_USERNAME=admin
      - KC_ADMIN_PASSWORD=admin
      - KEYCLOAK_ADMIN=admin
      - KEYCLOAK_ADMIN_PASSWORD=admin
    command: ["start-dev"]
    ports:
      - "8080:8080"
    depends_on:
      - db
    networks:
      - mohportal-network

volumes:
  postgres_data:
  redis_data:

networks:
  mohportal-network:
    driver: bridge