---
version: "2.1"
services:
  mailcatcher:
    image: jeanberu/mailcatcher:0.6.5
    ports:
      - "1080:1080"
      - "1025:1025"

  postgres:
    image:                 "postgres:13-alpine"
    environment:
      POSTGRES_USER:       "user"
      POSTGRES_PASSWORD:   "password"
    ports:
      - "5432:5432"
    volumes:
      - ./tmp/postgres/data:/var/lib/postgresql/data

  redis:
    image: redis:6.0-alpine
    command: redis-server
    expose:
      - "6379"
    volumes:
      - ./tmp/redis/data:/var/lib/redis/data
    healthcheck:
      test: "redis-cli ping"
      interval: 5s
      timeout: 5s
      retries: 10

  sidekiq:
    depends_on:
      - redis
      - postgres
    build: .
    command: bundle exec sidekiq -C config/sidekiq.yml
    volumes:
      - .:/app
    env_file:
      - ".env.docker"

  webpacker:
    build: .
    environment:
      - WEBPACKER_DEV_SERVER_HOST=0.0.0.0
    env_file:
      - ".env.docker"
    command: ./bin/webpack-dev-server
    volumes:
      - .:/app
    ports:
      - "3035:3035"
      - "8080:8080"

  app:
    build: .
    depends_on:
      - postgres
      - redis
      - mailcatcher
      - webpacker
    ports:
      - "3000:3000"
    volumes:
      - ".:/app"
    shm_size: 512M # https://testingrepository.com/fix-no-session-chromedriver-error/
    stdin_open: true
    tty: true
    env_file:
      - ".env.docker"
