Skip to content

feat(docker): add Docker Compose for local development with PostGIS#614

Open
NteinPrecious wants to merge 1 commit into
PinSpace-Org:mainfrom
NteinPrecious:issue/91-docker-compose-local-dev
Open

feat(docker): add Docker Compose for local development with PostGIS#614
NteinPrecious wants to merge 1 commit into
PinSpace-Org:mainfrom
NteinPrecious:issue/91-docker-compose-local-dev

Conversation

@NteinPrecious

Copy link
Copy Markdown
Contributor

Summary

Closes #91

Adds a root-level docker-compose.yml for one-command local development, and a Backend/Dockerfile.dev for hot-reload development. Also fixes the existing infrastructure/docker/ setup which was using plain Postgres without PostGIS — a hard requirement for the app's geospatial queries.

Changes

New files

docker-compose.yml (root — local dev entry point)

  • Uses postgis/postgis:16-3.4-alpine so PostGIS is available immediately
  • Backend service mounts source code and runs npm run start:dev (hot reload via NestJS watch mode)
  • Database env vars (DATABASE_HOST, DATABASE_PORT, etc.) match what the backend expects
  • Supports an optional ./Backend/.env override via env_file
  • Postgres healthcheck gates backend startup

Backend/Dockerfile.dev

  • Lightweight dev image (node:20-alpine) — installs all deps and starts in watch mode
  • Distinct from the multi-stage production backend.Dockerfile

Updated files

infrastructure/docker/postgres-init.sql

  • Added CREATE EXTENSION IF NOT EXISTS postgis and postgis_topology — without these the app's PostGIS migrations and ST_DWithin queries fail on first boot

infrastructure/docker/docker-compose.yml

  • Swapped postgres:16-alpinepostgis/postgis:16-3.4-alpine
  • Replaced DATABASE_URL (not used by the backend) with the individual DATABASE_* env vars the app actually reads
  • Mounts the init SQL so PostGIS extensions are bootstrapped on first run

Usage

# copy and fill in optional vars (Pinata, Stellar) — DB vars are pre-set by compose
cp Backend/.env.example Backend/.env

# start everything
docker compose up --build

# backend available at http://localhost:3000
# swagger docs at   http://localhost:3000/api/docs
# metrics at        http://localhost:3000/metrics

Test plan

  • docker compose up --build — postgres and backend both come up healthy
  • curl http://localhost:3000/health — returns { "status": "ok" }
  • Edit a source file — confirm NestJS hot reload picks up the change without restarting the container
  • docker compose down -v && docker compose up --build — clean boot with PostGIS extensions created on first run (check logs for CREATE EXTENSION)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Docker Compose for local development

1 participant