generated from bisco/codex-bootstrap
chore: rename postgres service to db
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
POSTGRES_DB=theatre_lab
|
||||
POSTGRES_USER=theatre_lab
|
||||
POSTGRES_PASSWORD=replace-with-a-local-password
|
||||
DATABASE_URL=postgresql://theatre_lab:replace-with-a-local-password@postgres:5432/theatre_lab
|
||||
DATABASE_URL=postgresql://theatre_lab:replace-with-a-local-password@db:5432/theatre_lab
|
||||
DJANGO_SECRET_KEY=replace-with-a-long-random-development-key
|
||||
DJANGO_DEBUG=true
|
||||
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,backend,azionelab.org
|
||||
|
||||
@@ -12,7 +12,7 @@ stores content, and Docker Compose supplies a reproducible local environment.
|
||||
Italian fallback content for development when the CMS is unavailable.
|
||||
- `nginx/`: reverse-proxy virtual host for `azionelab.org`, routing public requests to
|
||||
Astro or Wagtail.
|
||||
- `postgres`: persistent CMS database.
|
||||
- `db`: persistent PostgreSQL database.
|
||||
- Docker volumes: `postgres_data` for the database and `media_data` for uploads.
|
||||
|
||||
See [the architecture document](docs/architecture.md),
|
||||
@@ -91,11 +91,15 @@ The frontend reads `PUBLIC_CMS_API_URL`; inside Compose it defaults to
|
||||
public reverse-proxy address. Change both values for another environment.
|
||||
The standard published-page endpoint is also available at `/api/v2/pages/`.
|
||||
|
||||
The PostgreSQL service is named `db`. Existing `.env` files should replace `@postgres:`
|
||||
with `@db:` in `DATABASE_URL`; a compatibility network alias keeps older local values
|
||||
working during the transition.
|
||||
|
||||
## Useful commands
|
||||
|
||||
```bash
|
||||
# Follow application logs
|
||||
docker compose logs -f postgres backend frontend proxy
|
||||
docker compose logs -f db backend frontend proxy
|
||||
|
||||
# Run database migrations
|
||||
docker compose exec backend python manage.py migrate
|
||||
@@ -137,7 +141,7 @@ Database rows and uploaded files must be backed up together:
|
||||
```bash
|
||||
mkdir -p backups/media
|
||||
docker compose stop frontend backend
|
||||
docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' > backups/database.sql
|
||||
docker compose exec -T db sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' > backups/database.sql
|
||||
docker compose cp backend:/app/media/. backups/media/
|
||||
docker compose start backend frontend
|
||||
```
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
services:
|
||||
postgres:
|
||||
db:
|
||||
image: postgres:16.9-alpine
|
||||
restart: unless-stopped
|
||||
init: true
|
||||
@@ -9,6 +9,10 @@ services:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-replace-with-a-local-password}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
default:
|
||||
aliases:
|
||||
- postgres
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
@@ -24,7 +28,7 @@ services:
|
||||
restart: unless-stopped
|
||||
init: true
|
||||
environment:
|
||||
DATABASE_URL: ${DATABASE_URL:-postgresql://theatre_lab:replace-with-a-local-password@postgres:5432/theatre_lab}
|
||||
DATABASE_URL: ${DATABASE_URL:-postgresql://theatre_lab:replace-with-a-local-password@db:5432/theatre_lab}
|
||||
DJANGO_SECRET_KEY: ${DJANGO_SECRET_KEY:-replace-with-a-long-random-development-key}
|
||||
DJANGO_DEBUG: ${DJANGO_DEBUG:-true}
|
||||
DJANGO_ALLOWED_HOSTS: ${DJANGO_ALLOWED_HOSTS:-localhost,127.0.0.1,backend,azionelab.org}
|
||||
@@ -34,7 +38,7 @@ services:
|
||||
ports:
|
||||
- "127.0.0.1:8000:8000"
|
||||
depends_on:
|
||||
postgres:
|
||||
db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/', timeout=2)"]
|
||||
|
||||
@@ -33,6 +33,10 @@ development.
|
||||
`PUBLIC_CMS_API_URL` must be reachable by Astro; within Compose it is
|
||||
`http://backend:8000`.
|
||||
|
||||
The PostgreSQL Compose service is `db`, so new `DATABASE_URL` values use `db:5432`.
|
||||
The internal `postgres` alias is retained only for compatibility with existing local
|
||||
`.env` files and should not be used in new configuration.
|
||||
|
||||
The local virtual host is HTTP-only. Production must publish NGINX through the intended
|
||||
network interface, configure DNS for `azionelab.org`, terminate TLS, and prevent direct
|
||||
external access to application ports.
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
```bash
|
||||
docker compose up --build -d
|
||||
docker compose ps
|
||||
docker compose logs -f proxy backend frontend postgres
|
||||
docker compose logs -f proxy backend frontend db
|
||||
docker compose down
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ Back up the database and media at the same logical point in time:
|
||||
```bash
|
||||
mkdir -p backups/media
|
||||
docker compose stop frontend backend
|
||||
docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' > backups/database.sql
|
||||
docker compose exec -T db sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' > backups/database.sql
|
||||
docker compose cp backend:/app/media/. backups/media/
|
||||
docker compose start backend frontend
|
||||
```
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
1. Check `docker compose ps` and the backend health status.
|
||||
2. Request `http://azionelab.org:8080/api/site/home/` through NGINX.
|
||||
3. Inspect `docker compose logs backend postgres`.
|
||||
3. Inspect `docker compose logs backend db`.
|
||||
4. Verify `PUBLIC_CMS_API_URL` resolves from the frontend container.
|
||||
5. Restart the frontend after recovery so its static page is rebuilt from CMS data.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user