This file provides context for AI assistants (Claude Code and others) working in this repository.
This is a minimal, focused accelerator for spinning up a local PostgreSQL + pgAdmin development environment using Docker Compose. The scope is intentionally limited to these two services. Do not add additional services (Redis, other databases, etc.) unless explicitly requested.
| File | Purpose |
|---|---|
start.sh |
Main script: prunes Docker, starts containers, polls for pgAdmin readiness, opens browser |
stop.sh |
Stops and removes containers (data in volumes persists) |
reset_env_variables.sh |
Unsets all project environment variables so Docker Compose defaults take effect |
docker-compose.postgres.yml |
Defines the postgres and pgAdmin services, volumes, and network |
.env |
Local overrides (git-ignored — do not commit) |
.env-sample |
Template for .env — copy this to get started |
.env-none |
Empty stub used when no .env file is present |
cp .env-sample .env # optional: customize versions/ports/credentials
./start.sh # starts containers and opens pgAdmin in the browser
./stop.sh # stops containers (data persists in Docker volumes)All variables have defaults built into docker-compose.postgres.yml. Override any of them in .env or by exporting them in your shell.
| Variable | Default | Description |
|---|---|---|
PG_VERSION |
18.3 |
Postgres image version (Alpine-based) |
PG_CONTAINER |
pg-docker |
Container name |
PG_PORT |
5432 |
Host port mapped to Postgres |
PG_USER |
postgres |
Database username |
PG_PASS |
docker |
Database password |
| Variable | Default | Description |
|---|---|---|
PGA_VERSION |
latest |
pgAdmin image version |
PGA_CONTAINER |
pg-admin |
Container name |
PGA_PORT |
8010 |
Host port for the pgAdmin web UI |
PGA_USER |
[email protected] |
pgAdmin login email |
PGA_PASS |
pass |
pgAdmin login password |
| Variable | Default | Description |
|---|---|---|
PG_NETWORK |
postgres |
Docker network shared by both containers |
DOT_ENV_FILE |
.env |
Path to the env file passed to Docker Compose |
These defaults are fine for local development. Change credentials before any deployment.
| Flag | Description |
|---|---|
-b / --build |
Rebuild Docker images before starting |
-r / --reset_env |
Source reset_env_variables.sh to unset all env vars before starting |
Both shell scripts and Markdown files are linted. Always ensure changes pass lint before committing.
All .sh files must pass ShellCheck. The .shellcheckrc disables three rules project-wide:
SC1091— not following sourced files (used inreset_env_variables.shsourcing)SC2153— possible variable name misspelling (false positives in this codebase)SC2317— unreachable commands (false positive in trap/signal handlers)
Run locally with the ShellCheck VS Code extension (timonwong.shellcheck) or the CLI.
Markdown is linted with markdownlint-cli2. Config is in .markdownlint-cli2.jsonc:
- Max line length: 240
- Allowed inline HTML:
<a>,<img>,<p> CLAUDE.mdand.github/copilot-instructions.mdare excluded from linting
Run manually:
markdownlint-cli2 '**/*.md'The markdownlint-cli2 version is pinned in .tool-versions (managed with asdf).
When modifying or adding shell scripts, follow the conventions established in start.sh:
- Wrap logic in a named function (e.g.,
function start()) called at the end of the file - Use lowercase local variables inside functions
- Use the color variables for all output:
blue(info),green(success),yellow(warning/action),red(error/destructive) - Always reset color with
${nc}after colored output - Use
echo -efor colored output; use>&2 echo -efor warnings and errors - Nested functions (e.g., helpers, progress, signal handlers) belong inside the outer function
- Scripts must be ShellCheck-compliant (see Linting above)
Edit .env (or .env-sample if updating the template default):
PG_VERSION=16.2
PGA_VERSION=8.0Then restart with a rebuild: ./start.sh -b
./start.sh -rThis unsets all env vars so Docker Compose falls back to its built-in defaults.
start.sh polls localhost:$PGA_PORT up to 35 times (1-second intervals). If it times out:
- Check that Docker Desktop is running
- Run
docker compose -f docker-compose.postgres.yml logsto inspect container output - Check for port conflicts on
5432or8010(or your custom ports) - Try
./start.sh -bto force a clean rebuild
Use the Docker network name (default: postgres) to connect other containers on the same host. The internal hostname is the container name (default: pg-docker), port 5432.
For host-based connections (e.g., from a local app not in Docker), use localhost and PG_PORT (default: 5432).
Override the conflicting port in .env:
PG_PORT=5433
PGA_PORT=8011