version: '2'
services:
  db:
    container_name: scinote_db_production
    image: postgres:11
    volumes:
      - scinote_production_postgres:/var/lib/postgresql/data

  web:
    build:
      context: .
      dockerfile: Dockerfile.production
    image: scinote_web_production
    container_name: scinote_web_production
    stdin_open: true
    env_file: ./production.env
    tty: true
    depends_on:
      - db
    ports:
      - "3000:3000"
    command: bash -c "rm -f /usr/src/app/tmp/pids/server.pid && rails s -b 0.0.0.0"
    environment:
      - RAILS_ENV=production
    volumes:
      - scinote_production_files:/usr/src/app/public/system
      - scinote_production_storage:/usr/src/app/storage

  jobs:
    image: scinote_web_production
    container_name: scinote_jobs_production
    tty: true
    depends_on:
      - db
    command: rake jobs:work
    env_file: ./production.env
    environment:
      - RAILS_ENV=production
    volumes:
      - scinote_production_files:/usr/src/app/public/system
      - scinote_production_storage:/usr/src/app/storage

volumes:
  scinote_production_postgres:
  scinote_production_files:
  scinote_production_storage: