c_agri_trade/project_code/docs/development/docker-compose.md

56 lines
3.1 KiB
Markdown

# Local development services
Docker Compose runs the ATB development dependencies without installing PostgreSQL, Keycloak, or Valkey on the host. This setup is for a developer workstation only.
## Start
Prerequisites: Docker Engine or Docker Desktop with the Compose plugin.
```bash
if [ ! -f project_code/.env ]; then
cp project_code/.env.example project_code/.env
fi
# Change the example local-only passwords in .env.
docker compose \
--env-file project_code/.env \
-f project_code/compose.yaml \
up -d
docker compose \
--env-file project_code/.env \
-f project_code/compose.yaml \
ps
```
The services publish ports on loopback only:
| Service | Host address | Development use |
|---|---|---|
| PostgreSQL | `127.0.0.1:5432` | `atb` database and user from `.env` |
| Keycloak | <http://localhost:8080> | Local identity server; admin credentials from `.env` |
| Valkey | `127.0.0.1:6379` | Local cache/stream dependency |
| Backend | `127.0.0.1:8000` | FastAPI application API (Swagger docs at `/docs`) |
| Frontend | `http://localhost:3000` | Hardened Nginx reverse proxy & React SPA portal |
PostgreSQL also creates a separate `keycloak` database and login for Keycloak. Both databases share one local PostgreSQL container; this is a workstation convenience, not a production isolation recommendation. PostgreSQL data survives `docker compose down` in the named `postgres_data` volume. Valkey is intentionally ephemeral because the durable outbox belongs in PostgreSQL.
Keycloak runs `start-dev`, uses the PostgreSQL service, and exposes its readiness check internally. Create any local realm/client configuration needed by the application in the Keycloak admin console; no product-specific realm/client settings are assumed here.
## Stop and reset
```bash
docker compose \
--env-file project_code/.env \
-f project_code/compose.yaml \
down
```
To erase the local PostgreSQL data as well, add `--volumes` to the `down` command. This deletes local database contents.
## Image provenance and scope
The example uses the [PostgreSQL Docker Official Image](https://hub.docker.com/_/postgres), [Keycloak's official container image](https://www.keycloak.org/server/containers) from `quay.io/keycloak/keycloak`, and the [Valkey project's image](https://hub.docker.com/r/valkey/valkey). Release tags are pinned in `project_code/.env.example`; they are not immutable digest pins, and this repository has not configured image signature verification or a vendor certification policy. Review and update the selected tags through normal dependency maintenance.
The Compose project includes the core FastAPI backend API and hardened React SPA frontend services authored during Construction iterations, building directly from `docker/Dockerfile.backend` and `docker/Dockerfile.frontend`. Mail capture, object-storage emulation, and external observability services remain optional overlays until their iteration needs and providers are selected.
This Compose configuration does not select a production runtime, change the approved production availability/recovery requirements, or demonstrate production readiness. Production hosting and its evidence gates remain open in the deployment design.