Skip to content

Commit f25b24c

Browse files
committed
chore(docs): update deployment instructions for Docker Compose with host DB/Redis
- Revised `Deployment_Production.md` to clarify usage of `docker-compose.host-db.yml` for running the API with PostgreSQL and Redis on the host. - Added details on environment variable requirements and updated health check instructions to reflect port changes. - Improved clarity on deployment methods and removed outdated sections regarding full-stack deployments.
1 parent a99189a commit f25b24c

File tree

2 files changed

+27
-37
lines changed

2 files changed

+27
-37
lines changed

docker/docker-compose.host-db.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Run only the API container, using PostgreSQL and Redis on the host.
22
# Use when DB and Redis are already running on the server (e.g. notes_dwh, system Redis).
33
#
4-
# Usage:
5-
# docker compose -f docker/docker-compose.host-db.yml up -d --build
4+
# Usage (from project root; --env-file .env loads .env from project root):
5+
# docker compose -f docker/docker-compose.host-db.yml --env-file .env up -d --build
66
#
77
# Requires .env with DB_* and REDIS_* (DB_HOST/REDIS_HOST are overridden to host.docker.internal).
88

docs/Deployment_Production.md

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -228,76 +228,66 @@ redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_PASSWORD ping
228228

229229
## Deployment
230230

231-
### Method 1: Docker Compose v2 (Recommended)
231+
**Note**: The server uses Docker Compose v2 (plugin), use `docker compose` (not `docker-compose`). On this server, **PostgreSQL (Analytics/Ingestion) and Redis run on the host**, not in containers—so the recommended Docker option is **API only** with `docker-compose.host-db.yml`.
232232

233-
**Note**: The server uses Docker Compose v2 (plugin), use `docker compose` (not `docker-compose`).
233+
### Method 1: Docker Compose – API only, host DB/Redis (Recommended for this server)
234+
235+
Use when PostgreSQL and Redis already run on the host (e.g. `notes_dwh`, system Redis). Only the API runs in a container; it connects to the host via `host.docker.internal`.
234236

235237
#### Initial Deployment
236238

237239
```bash
238-
# Navigate to application directory
239240
cd /opt/osm-notes-api
240241

241-
# Build and start services
242-
docker compose -f docker/docker-compose.yml up -d
242+
# Ensure .env has DB_PASSWORD (use double quotes if password contains #)
243+
# --env-file .env loads variables from project root (Compose otherwise looks in docker/)
244+
docker compose -f docker/docker-compose.host-db.yml --env-file .env up -d --build
243245

244246
# Check status
245-
docker compose -f docker/docker-compose.yml ps
247+
docker compose -f docker/docker-compose.host-db.yml ps
246248

247249
# View logs
248-
docker compose -f docker/docker-compose.yml logs -f api
250+
docker compose -f docker/docker-compose.host-db.yml logs -f api
249251
```
250252

251253
#### Verify Deployment
252254

253255
```bash
254-
# Health check
256+
# Health check (port from .env PORT, default 3010)
255257
curl -H "User-Agent: Monitor/1.0 (ops@example.com)" \
256-
http://localhost:3000/health
258+
http://localhost:3010/health
257259

258-
# Expected response:
259-
# {
260-
# "status": "healthy",
261-
# "timestamp": "...",
262-
# "database": { "status": "up", ... },
263-
# "redis": { "status": "up", ... }
264-
# }
265-
266-
# Test API endpoint
267-
curl -H "User-Agent: TestApp/1.0 (test@example.com)" \
268-
http://localhost:3000/notes-api/v1/analytics/global
260+
# Version headers
261+
curl -sI -H "User-Agent: Test/1.0 (a@b.com)" http://localhost:3010/health | grep -i x-api
269262
```
270263

271264
#### Update Deployment
272265

273266
```bash
274-
# Pull latest code
275267
cd /opt/osm-notes-api
276268
git pull origin main
277269

278-
# Rebuild and restart
279-
docker compose -f docker/docker-compose.yml up -d --build
270+
docker compose -f docker/docker-compose.host-db.yml --env-file .env up -d --build
280271

281-
# Verify
282-
curl -H "User-Agent: Monitor/1.0 (ops@example.com)" \
283-
http://localhost:3000/health
272+
curl -H "User-Agent: Monitor/1.0 (ops@example.com)" http://localhost:3010/health
284273
```
285274

286-
#### API only with host PostgreSQL and Redis
275+
To remove leftover postgres/redis containers from a previous full-stack run:
276+
`docker compose -f docker/docker-compose.host-db.yml down --remove-orphans`
287277

288-
When PostgreSQL and Redis already run on the host (e.g. `notes_dwh`, system Redis), run only the API container and point it at the host:
278+
Requires Docker 20.10+ (for `host-gateway`). Port mapping: `${PORT:-3010}:3000`.
289279

290-
```bash
291-
cd /opt/osm-notes-api
280+
### Alternative: Docker Compose full stack (API + Postgres + Redis in containers)
292281

293-
# Ensure .env has DB_PASSWORD (use double quotes if password contains #)
294-
# DB_HOST/REDIS_HOST are overridden to host.docker.internal by this compose
282+
Use only if you want the API, PostgreSQL, and Redis **all in containers** (e.g. testing or a environment without a host DB). Not for this server when Analytics/Ingestion DB and Redis are on the host.
295283

296-
docker compose -f docker/docker-compose.host-db.yml up -d --build
284+
```bash
285+
cd /opt/osm-notes-api
286+
# Requires .env with DB_PASSWORD set (used by the postgres container)
287+
docker compose -f docker/docker-compose.yml up -d --build
288+
docker compose -f docker/docker-compose.yml ps
297289
```
298290

299-
The API will connect to the host via `host.docker.internal` (requires Docker 20.10+ with `host-gateway`). Port defaults to `${PORT:-3010}:3000`.
300-
301291
### Method 2: Docker Standalone
302292

303293
```bash

0 commit comments

Comments
 (0)