version: "3.9"

services:
  postgres:
    image: postgres:17.2
    container_name: code_journey_db
    restart: unless-stopped
    environment:
      POSTGRES_DB: code_journey
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - app_net

  backend:
    build: ./backend
    container_name: code_journey_backend
    restart: unless-stopped
    depends_on:
      - postgres
    environment:
      SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/code_journey
      SPRING_DATASOURCE_USERNAME: postgres
      SPRING_DATASOURCE_PASSWORD: postgres
    ports:
      - "8080:8080"
    networks:
      - app_net

  frontend:
    build: ./frontend
    container_name: code_journey_frontend
    restart: unless-stopped
    depends_on:
      - backend
    environment:
      NEXT_PUBLIC_API_URL: http://backend:8080
    ports:
      - "3000:3000"
    networks:
      - app_net

volumes:
  postgres_data:

networks:
  app_net:
    driver: bridge
