1.8 KiB · text History 7f67051
services:
  postgres:
    image: postgres:16
    environment:
      POSTGRES_DB: app
      POSTGRES_USER: app_user
      POSTGRES_PASSWORD: app_password
    ports:
      - "5433:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U app_user -d app"]
      interval: 5s
      timeout: 3s
      retries: 10
  rabbitmq:
    image: rabbitmq:3-management-alpine
    environment:
      RABBITMQ_DEFAULT_USER: app_user
      RABBITMQ_DEFAULT_PASS: app_password
    ports:
      - "5674:5672"    # AMQP
      - "15674:15672"  # management UI
    healthcheck:
      test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
      interval: 10s
      timeout: 5s
      retries: 10

  webservice:
    build:
      context: .
    # Named per project, not a shared `app:local`: compose reuses an existing
    # image of this name instead of building, so a generic name makes `up`
    # silently start whichever generated project built it last (whose
    # migrations then don't match this database).
    image: recourse:local
    depends_on:
      postgres: { condition: service_healthy }
      rabbitmq: { condition: service_healthy }
    environment:
      DATABASE_URL: postgres://app_user:app_password@postgres:5432/app
      AMQP_URL: amqp://app_user:app_password@rabbitmq:5672/%2f
      BIND_ADDRESS: 0.0.0.0:3999
      AUTO_MIGRATE: "true"
      REGISTRATION_ENABLED: "false"
    ports:
      - "3999:3999"

  worker:
    image: recourse:local
    # Reuse the image built by `webservice`; wait for it so migrations run first.
    depends_on:
      webservice: { condition: service_started }
    environment:
      DATABASE_URL: postgres://app_user:app_password@postgres:5432/app
      AMQP_URL: amqp://app_user:app_password@rabbitmq:5672/%2f
    command: ["app-queue-worker"]

volumes:
  postgres_data: