services:
  app_proxy:
    environment:
      APP_HOST: public-pool-web_rails-app_1
      APP_PORT: 3000

  rails-app:
    image: martinbarilik/public-pool-web:0.1.0@sha256:943270bc7e5c01ee713f74fec77c3e159db8f3b599e71f324b08d39e8d88a37c
    user: "1000:1000"
    environment:
      - RAILS_MASTER_KEY=${APP_PUBLIC_POOL_WEB_MASTER_KEY}
      - DATABASE_URL=${APP_PUBLIC_POOL_WEB_DATABASE_URL}
      - REDIS_URL=${APP_PUBLIC_POOL_WEB_REDIS_URL}
    depends_on:
      db:
        condition: service_healthy
      redis: 
        condition: service_healthy
        
  db:
    image: postgres:17.6@sha256:8a56bef4c60bef3d26193cb9d810fce93def8fd0c459f4a9b14240fbd7559a1d
    user: "1000:1000"
    environment:
      - POSTGRES_USER=${APP_PUBLIC_POOL_WEB_POSTGRES_USERNAME}
      - POSTGRES_PASSWORD=${APP_PUBLIC_POOL_WEB_POSTGRES_PASSWORD}
      - POSTGRES_DB=${APP_PUBLIC_POOL_WEB_POSTGRES_DBNAME}
    volumes:
      - ${APP_DATA_DIR}/data/postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${APP_PUBLIC_POOL_WEB_POSTGRES_USERNAME} -d ${APP_PUBLIC_POOL_WEB_POSTGRES_DBNAME}"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7.4.2@sha256:fbdbaea47b9ae4ecc2082ecdb4e1cea81e32176ffb1dcf643d422ad07427e5d9
    user: "1000:1000"
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - ${APP_DATA_DIR}/data/redis:/data

  sidekiq:
    image: martinbarilik/public-pool-web:0.1.0@sha256:943270bc7e5c01ee713f74fec77c3e159db8f3b599e71f324b08d39e8d88a37c
    user: "1000:1000"
    environment:
      - RAILS_MASTER_KEY=${APP_PUBLIC_POOL_WEB_MASTER_KEY}
      - REDIS_URL=${APP_PUBLIC_POOL_WEB_REDIS_URL}
      - DATABASE_URL=${APP_PUBLIC_POOL_WEB_DATABASE_URL}
    command: bundle exec sidekiq
    depends_on:
      - redis
      - db
      - rails-app

