version: "3.8"

services:
  # Frontend - Puerto 9112
  codigo0-frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: codigo0-frontend
    restart: always
    ports:
      - "9112:9112"
    networks:
      - proxy
    environment:
      - VITE_API_URL=http://codigo0-backend:3000/api

  # Backend - Puerto 3000
  codigo0-backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: codigo0-backend
    restart: always
    ports:
      - "3000:3000"
    networks:
      - proxy
    environment:
      - PORT=3000
      - NODE_ENV=production
      - MONGODB_URI=mongodb://mongodb:27017/codigo0
      - CORS_ORIGIN=*

  # MongoDB
  mongodb:
    image: mongo:latest
    container_name: codigo0-mongodb
    ports:
      - "27017:27017"
    restart: always
    volumes:
      - mongodb_data:/data/db
    networks:
      - proxy

networks:
  proxy:
    external: true

volumes:
  mongodb_data:
