services:

  # Usefull only to use the real time collaboration
  redis:
    image: redis:latest
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
      interval: 1s
      timeout: 3s
      retries: 5
    command: ["redis-server"]

  db:
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U postgres" ]
      interval: 2s
    image: postgis/postgis:14-3.3-alpine
    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust
    volumes:
      - db:/var/lib/postgresql/data

  app:
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    image: umap/umap:3.0.2
    environment:
      - STATIC_ROOT=/srv/umap/static
      - MEDIA_ROOT=/srv/umap/uploads
      - DATABASE_URL=postgis://postgres@db/postgres
      - SECRET_KEY=some-long-and-weirdly-unrandom-secret-key
      - SITE_URL=https://umap.local/
      - UMAP_ALLOW_ANONYMOUS=True
      - DEBUG=1
      - REALTIME_ENABLED=1
      - REDIS_URL=redis://redis:6379
    volumes:
      - data:/srv/umap/uploads
      - static:/srv/umap/static

  proxy:
    image: nginx:latest
    ports:
      - "8000:80"
    volumes:
      - ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
      - static:/static:ro
      - data:/data:ro
    depends_on:
      - app

volumes:
  data:
  static:
  db:
