version: "2"
services:
  gmus-backend:
    container_name: gmus-backend
    build:
      context: .
    volumes:
      - .:/app
      - /app/bin
    links:
      - gmus-db:db
      - gmus-redis:redis
    networks:
      - net_gmus_dev
    ports:
      - 3002:80
    env_file:
      - .env
    environment:
      GO_ENV: development
      HOST: 0.0.0.0
      PORT: 80
      POSTGRES_HOST: db
      POSTGRES_DATABASE: music_player
      POSTGRES_USER: docker
      POSTGRES_PASSWORD: docker
      POSTGRES_PORT: 5432
      REDIS_URL: redis:6379

  gmus-db:
    restart: always
    image: postgres:10.4
    networks:
      - net_gmus_dev
    ports:
      - 5417:5432
    environment:
      POSTGRES_USER: docker
      POSTGRES_PASSWORD: docker
    volumes:
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql

  gmus-redis:
    restart: always
    image: redis:6-alpine
    networks:
      - net_gmus_dev
    ports:
      - 6381:6379

networks:
  net_gmus_dev:
    driver: bridge
