version: "2"
services:
  gmusic:
    container_name: gmusic
    build:
      context: .
    volumes:
      - .:/app
    links:
      - music-player-db:db
      - music-player-redis:redis
    networks:
      - net_gmusic_dev
    ports:
      - ${PORT}:3000
    env_file:
      - .env
    environment:
      GO_ENV: development
      PORT: 3000
      DATABASE_URL: postgres://docker:docker@db:5432/music_player
      REDIS_URL: redis:6379

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

  music-player-redis:
    restart: always
    image: redis:6-alpine
    networks:
      - net_gmusic_dev
    ports:
      - 6381:6379

networks:
  net_gmusic_dev:
    driver: bridge
