version: "2.4"

services:
  production_database:
    image: postgres:12-alpine
    environment:
      PGDATA: /var/lib/postgresql/data/pgdata
      POSTGRES_PASSWORD: mysecretpassword
    volumes:
      - osem_production_database:/var/lib/postgresql/data/pgdata
  production_web:
    build:
      context: .
      dockerfile: Dockerfile.production
    depends_on:
      - production_database
    ports:
      - 8080:3000
    env_file: .env.production # see dotenv.example file
    environment:
     OSEM_DB_HOST: production_database
     RAILS_SERVE_STATIC_FILES: 'true'
    command: foreman start -p 3000
    volumes:
      - osem_production_web_data:/osem/public/system
      - osem_production_web_assets:/osem/public/assets
      - osem_production_web_logs:/osem/log

# named volumes to persist data
volumes:
  osem_production_database:
  osem_production_web_data:
  osem_production_web_assets:
  osem_production_web_logs:
