services:
  coder:
    image: ghcr.io/coder/coder:v2.15.3

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    group_add:
      - "998"
    depends_on:
      db:
        condition: service_healthy
    environment:
      - CODER_ACCESS_URL
      - CODER_HTTP_ADDRESS
      - CODER_PG_CONNECTION_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db/${POSTGRES_DB}?sslmode=disable

  db:
    image: postgres:17

    environment:
      - POSTGRES_PASSWORD
      - POSTGRES_USER
      - POSTGRES_DB
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}",
        ]
      interval: 5s
      timeout: 5s
      retries: 5
    volumes:
      - db_coder_data:/var/lib/postgresql/data

volumes:
  db_coder_data: