Docker Compose for Hasura + PostgreSQL
Hasura GraphQL Engine with PostgreSQL. Instant GraphQL API over your database.
hasura graphql postgres api
compose.yaml
services:
hasura:
image: hasura/graphql-engine:latest
ports:
- target: 8080
mode: ingress
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/hasura
- HASURA_GRAPHQL_ADMIN_SECRET=${HASURA_GRAPHQL_ADMIN_SECRET}
- HASURA_GRAPHQL_ENABLE_CONSOLE=true
healthcheck:
test:
- CMD
- curl
- -f
- http://localhost:8080/healthz
interval: 30s
timeout: 5s
retries: 3
depends_on:
- db
deploy:
resources:
reservations:
cpus: "0.5"
memory: 256M
restart: unless-stopped
db:
image: postgres:16
ports:
- target: 5432
mode: host
environment:
- POSTGRES_DB=hasura
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
healthcheck:
test:
- CMD-SHELL
- pg_isready -U postgres
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
reservations:
cpus: "0.5"
memory: 256M
restart: unless-stopped
x-defang-postgres: true
Services
- hasura hasura/graphql-engine:latest
- db postgres:16