# Moving a PostgreSQL database into RasterizedDB. `source` is a PostgreSQL 17 # container seeded from seed.sql; `import` copies its schema and rows into a # new RasterizedDB database and exits; `rasterizeddb` then serves the result. # Copy .env.example to .env first. Steps are in README.md. name: rasterizeddb-import services: source: image: postgres:17 environment: POSTGRES_PASSWORD: ${SOURCE_PASSWORD:?set SOURCE_PASSWORD in .env} POSTGRES_DB: shop volumes: - source-data:/var/lib/postgresql/data - ./seed.sql:/docker-entrypoint-initdb.d/seed.sql:ro healthcheck: # Over TCP, so it passes only once the real server is up (the image's # first-run setup listens on a local socket only). test: ["CMD", "pg_isready", "-h", "127.0.0.1", "-U", "postgres", "-d", "shop"] interval: 5s timeout: 5s retries: 24 # One-shot: docker compose run --rm import # It uses the server's data volume, so the server must be stopped while it # runs (a running server holds the directory's lock and the import refuses). import: image: ${RASTERIZEDDB_IMAGE:-milendenev/rasterizeddb:1.1.0} profiles: ["import"] environment: RASTERIZEDDB_PG_PASSWORD: ${RASTERIZEDDB_PG_PASSWORD:?set RASTERIZEDDB_PG_PASSWORD in .env} # The source's password, read by the import (kept out of the URI and # the command line). PGPASSWORD: ${SOURCE_PASSWORD:?set SOURCE_PASSWORD in .env} command: - --pg-import-from - postgresql://postgres@source:5432/shop?sslmode=disable - --pg-import-into - shop volumes: - data:/var/lib/rasterizeddb depends_on: source: condition: service_healthy 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"] ports: - "127.0.0.1:5432:5432" - "127.0.0.1:61170:61170" 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 volumes: data: source-data: