version: "3.8"

services:
  web:
    build: .
    volumes:
      - ./log:/rails/log
      - ./storage:/rails/storage
    ports:
      - "3000:3000"
    environment:
      - REDIS_URL=redis://redis-db:6379
      - DATABASE_URL=postgres://root:password@postgres-db/
    secrets:
      - source: master_key
        target: /rails/config/master.key
    depends_on:
      redis-db:
        condition: service_started
      postgres-db:
        condition: service_healthy

  postgres-db:
    image: postgres
    environment:
      POSTGRES_USER: root
      POSTGRES_PASSWORD: password
    volumes:
      - ./tmp/postgres-db:/var/lib/postgresql/data
    healthcheck:
      test: pg_isready
      interval: 2s
      timeout: 5s
      retries: 30

  redis-db:
    image: redis

secrets:
  master_key:
    file: ./config/master.key
