version: "3.8"

services:
  # Spring Boot 백엔드
  backend:
    build:
      context: ../../backend-spring
      dockerfile: ../docker/deploy/backend-spring.Dockerfile
    container_name: pms-backend-prod
    restart: always
    environment:
      SPRING_PROFILES_ACTIVE: prod
      SERVER_PORT: "8081"
      SPRING_DATASOURCE_URL: jdbc:postgresql://183.99.177.40:5432/invyone
      SPRING_DATASOURCE_USERNAME: postgres
      SPRING_DATASOURCE_PASSWORD: "invyone0909!!"
      JWT_SECRET: ilshin-plm-super-secret-jwt-key-2024
      JWT_EXPIRATION: "86400000"
      FILE_UPLOAD_DIR: ./uploads
    volumes:
      - backend_uploads:/app/uploads
      - backend_data:/app/data
    labels:
      - traefik.enable=true
      - traefik.http.routers.backend.rule=Host(`api.invyone.com`)
      - traefik.http.routers.backend.entrypoints=websecure,web
      - traefik.http.routers.backend.tls=true
      - traefik.http.routers.backend.tls.certresolver=le
      - traefik.http.services.backend.loadbalancer.server.port=8081

  # Next.js 프론트엔드
  frontend:
    build:
      context: ../../frontend
      dockerfile: ../docker/deploy/frontend.Dockerfile
      args:
        - NEXT_PUBLIC_API_URL=https://api.invyone.com/api
    container_name: pms-frontend-prod
    restart: always
    environment:
      NODE_ENV: production
      NEXT_PUBLIC_API_URL: https://api.invyone.com/api
      SERVER_API_URL: "http://backend:8081"
      NEXT_TELEMETRY_DISABLED: "1"
      PORT: "3000"
      HOSTNAME: 0.0.0.0
    volumes:
      - frontend_data:/app/data
    labels:
      - traefik.enable=true
      - traefik.http.routers.frontend.rule=Host(`v1.invyone.com`)
      - traefik.http.routers.frontend.entrypoints=websecure,web
      - traefik.http.routers.frontend.tls=true
      - traefik.http.routers.frontend.tls.certresolver=le
      - traefik.http.services.frontend.loadbalancer.server.port=3000

volumes:
  backend_uploads:
    driver: local
  backend_data:
    driver: local
  frontend_data:
    driver: local

networks:
  default:
    name: toktork_server_default
    external: true
