version: "3"

services:
  adminer:
    image: adminer:4.8.1-standalone
    restart: always
    ports:
      - 8070:8080
    networks:
      - eaglecast-dev

  mailhog:
    image: mailhog/mailhog:v1.0.1
    ports:
      - "1025:1025" # SMTP
      - "8025:8025" # UI
    networks:
      - eaglecast-dev

  db:
    image: postgres:13
    ports:
      - "5432:5432"
    networks:
      - eaglecast-dev
    environment:
      - POSTGRES_PASSWORD=eaglecast-dev
      - POSTGRES_USER=eaglecast-dev
      - POSTGRES_DB=eaglecast-dev
    restart: unless-stopped
    volumes:
      - type: volume
        source: eaglecast-dev-db
        target: /var/lib/postgresql/data

  front:
    build:
      context: ../
      dockerfile: dev/app.Dockerfile
    command: ["make", "run-frontend"]
    ports:
      - "8080:8080"
    environment:
      - EAGLECAST_API_URL=http://backend:9000
    depends_on:
      - db
    volumes:
      - ../:/app
    networks:
      - eaglecast-dev

  backend:
    build:
      context: ../
      dockerfile: dev/app.Dockerfile
    command: ["make", "run-backend-docker"]
    ports:
      - "9000:9000"
    depends_on:
      - db
    volumes:
      - ../:/app
      - ${GOPATH:-${HOME}/go}/pkg/mod/cache:/go/pkg/mod/cache
    networks:
      - eaglecast-dev

volumes:
  eaglecast-dev-db:

networks:
  eaglecast-dev:
