version: "3.9"

services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: code_journey_backend
    restart: unless-stopped
    environment:
      SPRING_DATASOURCE_URL: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
      SPRING_DATASOURCE_USERNAME: ${DB_USER}
      SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD}
      SPRING_PROFILES_ACTIVE: prod
      JWT_SECRET: ${JWT_SECRET}
    networks:
      - app_net
      - proxy_net

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: code_journey_frontend
    restart: unless-stopped
    depends_on:
      - backend
    environment:
      NEXT_PUBLIC_API_URL: https://api.code-journey.com
      NODE_ENV: production
    networks:
      - app_net
      - proxy_net

networks:
  app_net:
    driver: bridge

  proxy_net:
    external: true
