hexlet-codebattle/codebattle

View on GitHub
docker-compose.yml

Summary

Maintainability
Test Coverage
version: "3.3"

services:
  app:
    build:
      context: services/app
      dockerfile: Dockerfile.dev
    working_dir: /app
    env_file: .env
    command: mix phx.server
    environment:
      - "USER=${USER}"
    ports:
      - "${CODEBATTLE_PORT}:${CODEBATTLE_PORT}"
      - "8080:8080"
    volumes:
      - "./services/app:/app:delegated"
      - "~/.bash_history:/root/.bash_history:delegated"
      - ".bashrc:/root/.bashrc:delegated"
      - "/var/run/docker.sock:/var/run/docker.sock:cached"
      - "/var/tmp:/var/tmp:delegated"
      - "/tmp:/tmp:delegated"
    depends_on:
      - db

  db:
    image: postgres:12-alpine
    environment:
      POSTGRES_USER: ${CODEBATTLE_DB_USERNAME}
      POSTGRES_PASSWORD: ${CODEBATTLE_DB_PASSWORD}
    volumes:
      - pg_data:/var/lib/postgresql/data

  # same db but forwards port to host
  db-local:
    image: postgres:12-alpine
    ports:
      - "5432:${CODEBATTLE_DB_PORT}"
    environment:
      POSTGRES_USER: ${CODEBATTLE_DB_USERNAME}
      POSTGRES_PASSWORD: ${CODEBATTLE_DB_PASSWORD}
    command: postgres -c 'max_connections=1000'
    volumes:
      - pg_data:/var/lib/postgresql/data

volumes:
  pg_data: