# One-command demo: QueryAPIGate in front of a PostgreSQL database that is seeded with sample films. # # docker compose up --build # curl -H 'X-API-Key: demo-key' 'http://127.0.0.1:5000/q/films_by_rating?rating=PG&max_length=90' # # Interactive docs: http://127.0.0.1:5000/docs (paste the key `demo-key` into the box at the top). # Stop and clean up with: docker compose down -v services: db: image: postgres:16-alpine environment: POSTGRES_PASSWORD: demo volumes: - ./demo/init.sql:/docker-entrypoint-initdb.d/init.sql:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 3s timeout: 3s retries: 20 queryapigate: build: . depends_on: db: condition: service_healthy ports: - "127.0.0.1:${QUERYAPIGATE_PORT:-5000}:5000" # only reachable from this machine environment: QUERYAPIGATE_API_KEY: demo-key # change it - or drop this line to run without authentication DEMO_DB_PASSWORD: demo # the demo connection's password is stored as ${DEMO_DB_PASSWORD} QUERYAPIGATE_RATE_LIMIT: 120/minute # Reuse the key, saved query and connection a call reads for 5 s instead of reading the store every time # (documentation/PERFORMANCE.md#the-metadata-cache). Safe with one instance: a change through the API or Console # is seen at once; one made with the CLI inside the container, up to 5 s later. 0 turns it off. QUERYAPIGATE_METADATA_CACHE_TTL: "5" volumes: - demo-data:/data healthcheck: # the image's own check, run more often so the seed starts sooner test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5000/health', timeout=3)"] interval: 3s timeout: 3s retries: 20 # A one-shot seed: once queryapigate is healthy, creates the demo connection and saved queries through the # Management API (demo/seed.sh) - the same calls the Console makes. Re-running it leaves existing ones alone. seed: image: curlimages/curl:8.10.1 depends_on: queryapigate: condition: service_healthy environment: QUERYAPIGATE_API_KEY: demo-key volumes: - ./demo/seed.sh:/seed.sh:ro entrypoint: ["sh", "/seed.sh"] volumes: demo-data: