Skip to content

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:

cp .env.example .env

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:

make setup PROFILE=test
make stats
make verify

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:

make setup PROFILE=small

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

docker compose ps
docker compose logs -f postgres
docker compose down

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:

make docs-build

Without Make:

docker compose --profile docs run --rm docs build --strict

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

docker compose ps
docker compose logs postgres

Confirm Docker has enough memory and that the configuration file at postgres/postgresql.conf is readable.

Recreate only a container

docker compose up -d --force-recreate postgres

This preserves the database volume. Continue with the operations guide once the environment is healthy.