services:
  mongodb:
    image: mongo:7
    container_name: svoya-igra-mongodb
    restart: always
    volumes:
      - mongodb_data:/data/db
    environment:
      - MONGO_INITDB_DATABASE=svoya-igra
    networks:
      - internal

  server:
    build:
      context: ./server
      dockerfile: Dockerfile
    container_name: svoya-igra-server
    restart: always
    environment:
      - PORT=3001
      - MONGODB_URI=mongodb://mongodb:27017/svoya-igra
      - NODE_ENV=production
      - CLIENT_URL=*
    depends_on:
      - mongodb
    volumes:
      - ./server/public:/app/public
    networks:
      - internal
      - services_proxy

  client:
    build:
      context: ./client
      dockerfile: Dockerfile
    container_name: svoya-igra-client
    restart: always
    depends_on:
      - server
    networks:
      - internal
      - services_proxy

volumes:
  mongodb_data:

networks:
  internal:
    driver: bridge
  services_proxy:
    external: true
