ops: add PostgreSQL compose deployment
Verify and deploy production / verify-and-deploy (push) Successful in 2m45s
Verify and deploy production / verify-and-deploy (push) Successful in 2m45s
This commit is contained in:
@@ -70,7 +70,7 @@ jobs:
|
||||
$SUDO ln -sfn "$DATA_ROOT/projects" "$RELEASE_DIR/data/projects"
|
||||
$SUDO ln -sfn "$DATA_ROOT/image-projects" "$RELEASE_DIR/data/image-projects"
|
||||
$SUDO chown -R root:root "$APP_ROOT"
|
||||
$SUDO chown -R "$SERVICE_USER:$SERVICE_USER" "$DATA_ROOT"
|
||||
$SUDO chown -R "$SERVICE_USER:$SERVICE_USER" "$DATA_ROOT/projects" "$DATA_ROOT/image-projects"
|
||||
$SUDO ln -sfn "$RELEASE_DIR" "$APP_ROOT/current"
|
||||
$SUDO rm -f /etc/rednote-tool-studio.password
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# PostgreSQL deployment
|
||||
|
||||
The production database runs through Docker Compose and is only exposed on the server loopback interface.
|
||||
It is managed independently from the application CI deployment.
|
||||
|
||||
- Database: `rednote_studio`
|
||||
- User: `rednote_studio`
|
||||
- Address from the host: `127.0.0.1:5432`
|
||||
- Persistent data: `/var/lib/rednote-tool-studio/postgres`
|
||||
- Password secret: `/etc/rednote-tool-studio/postgres-password`
|
||||
|
||||
Start or update it on the production host:
|
||||
|
||||
```bash
|
||||
docker compose -f /opt/rednote-tool-studio/postgres/compose.yml pull
|
||||
docker compose -f /opt/rednote-tool-studio/postgres/compose.yml up -d
|
||||
docker compose -f /opt/rednote-tool-studio/postgres/compose.yml ps
|
||||
```
|
||||
|
||||
The password file must already exist, be owned by root, and use mode `0600`. Never commit it to the repository.
|
||||
@@ -0,0 +1,33 @@
|
||||
name: rednote-tool-studio
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17-bookworm
|
||||
restart: unless-stopped
|
||||
shm_size: 256mb
|
||||
environment:
|
||||
POSTGRES_DB: rednote_studio
|
||||
POSTGRES_USER: rednote_studio
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets:
|
||||
- postgres_password
|
||||
ports:
|
||||
- "127.0.0.1:5432:5432"
|
||||
volumes:
|
||||
- /var/lib/rednote-tool-studio/postgres:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U rednote_studio -d rednote_studio"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 20s
|
||||
stop_grace_period: 60s
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
secrets:
|
||||
postgres_password:
|
||||
file: /etc/rednote-tool-studio/postgres-password
|
||||
Reference in New Issue
Block a user