# A sample application and RasterizedDB in one Compose project. The app # reaches the database by its service name, `rasterizeddb`, on the project's # private network; only the app's port is published. Copy .env.example to # .env first, then: docker compose up -d --build name: rasterizeddb-app services: rasterizeddb: image: ${RASTERIZEDDB_IMAGE:-milendenev/rasterizeddb:1.1.0} environment: RASTERIZEDDB_PG_PASSWORD: ${RASTERIZEDDB_PG_PASSWORD:?set RASTERIZEDDB_PG_PASSWORD in .env} command: ["--log-level", "warn"] # No ports published: only containers on this project's network reach # the database. Add "127.0.0.1:5432:5432" to reach it from the host too. volumes: - data:/var/lib/rasterizeddb restart: unless-stopped stop_grace_period: 60s healthcheck: test: ["CMD", "bash", "-c", "exec 3<>/dev/tcp/127.0.0.1/5432"] interval: 10s timeout: 5s retries: 6 start_period: 30s app: build: . environment: # libpq's own variables: psycopg, psql and most PostgreSQL drivers # read them. PGHOST: rasterizeddb PGPORT: "5432" PGUSER: rasterized PGPASSWORD: ${RASTERIZEDDB_PG_PASSWORD:?set RASTERIZEDDB_PG_PASSWORD in .env} PGDATABASE: postgres PGSSLMODE: require ports: - "127.0.0.1:8000:8000" depends_on: rasterizeddb: condition: service_healthy restart: unless-stopped volumes: data: