Run locally with Docker
Docker Compose runs PostgreSQL 17, optional pgAdmin, and an optional live MkDocs server. Run all commands from the repository root.
Configure local values
Create your local environment file once:
The checked-in defaults are suitable for a disposable local lab. Edit .env if ports conflict with services already running on your machine.
Is Make required?
No. The Makefile is an optional convenience layer over Docker Compose, shell scripts, and psql.
Use the Make workflow when GNU Make is installed, or use the equivalent commands below.
See Project layout for why both Makefile and compose.yaml are kept at the repository root.
Run with Make
Initialize and verify the fast test dataset:
This starts PostgreSQL, waits for readiness, creates the schema, seeds the selected dataset, and creates the intentionally imperfect baseline indexes. Use PROFILE=small when you are ready to observe meaningful local performance differences:
Run without Make
Run the underlying commands directly from the repository root:
docker compose up -d postgres
./scripts/wait-for-postgres.sh
docker compose exec -T postgres psql -v ON_ERROR_STOP=1 -U lab -d commerce_lab < sql/bootstrap/schema.sql
./scripts/seed.sh test
docker compose exec -T postgres psql -v ON_ERROR_STOP=1 -U lab -d commerce_lab < sql/indexes/baseline.sql
./scripts/verify.sh
For an observable laptop-sized dataset, replace ./scripts/seed.sh test with ./scripts/seed.sh small. If you changed POSTGRES_USER or POSTGRES_DB in .env, replace lab or commerce_lab in direct psql commands accordingly.
Start each service
| Goal | With Make | Without Make | Browser or connection |
|---|---|---|---|
| PostgreSQL only | make up |
docker compose up -d postgres |
localhost:5432 |
| PostgreSQL and pgAdmin | make ui |
docker compose --profile ui up -d |
http://localhost:5050 |
| Documentation site | make docs |
docker compose --profile docs up -d docs |
http://localhost:8000 |
| PostgreSQL shell | make shell |
docker compose exec postgres psql -U lab -d commerce_lab |
Interactive terminal |
The documentation image includes a pinned quiz plugin and supports live reload. Source changes under docs/ or in mkdocs.yml appear after refreshing the browser. Quiz progress is stored in the browser's local storage.
Inspect and stop containers
make down runs the same docker compose down command. It stops and removes containers while preserving the named PostgreSQL data volume.
Build the documentation without serving it
With Make:
Without Make:
The generated static site is written to site/, which is ignored by Git.
Reset the database
The database volume persists across normal restarts. make reset prints, but deliberately does not execute, the destructive reset command. If you intentionally want a fresh dataset, run the printed command yourself, then rerun setup.
Data deletion
Removing the Compose volume permanently deletes this lab's PostgreSQL data. Check that you are in the correct repository before executing the reset command.
Troubleshooting
A port is already in use
Change the matching value in .env, such as POSTGRES_PORT, PGADMIN_PORT, or DOCS_PORT, then restart the service.
PostgreSQL is not healthy
Confirm Docker has enough memory and that the configuration file at postgres/postgresql.conf is readable.
Recreate only a container
This preserves the database volume. Continue with the operations guide once the environment is healthy.