chore: bind-mount postgres/redis data dirs, update docs for pocketveto.org
- docker-compose.yml: replace named volumes with ./postgres/data and ./redis/data bind mounts - .gitignore: exclude postgres/ and redis/ data directories - DEPLOYING.md: update clone URL to public PocketVeto repo - UPDATING.md: fix paths (~/pocketveto), clone URL, webhook IDs Authored by: Jack Levy
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -15,5 +15,7 @@ frontend/.next/
|
||||
frontend/node_modules/
|
||||
frontend/out/
|
||||
|
||||
# Docker
|
||||
# Docker — bind-mount data directories (created on first run)
|
||||
postgres/
|
||||
redis/
|
||||
*.log
|
||||
|
||||
@@ -27,9 +27,8 @@ Google Trends (`pytrends`) needs no key.
|
||||
## 1. Get the code
|
||||
|
||||
```bash
|
||||
git clone https://git.jackhlevy.com/jack/civicstack.git
|
||||
# (Replace with your own fork URL or download a release from pocketveto.org)
|
||||
cd civicstack
|
||||
git clone https://git.jackhlevy.com/jack/PocketVeto.git pocketveto
|
||||
cd pocketveto
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
46
UPDATING.md
46
UPDATING.md
@@ -41,9 +41,9 @@ On the server, clone from your Gitea instance:
|
||||
|
||||
```bash
|
||||
ssh user@YOUR_SERVER_IP
|
||||
cd /opt # or wherever you want to host it
|
||||
git clone https://YOUR_GIT_REMOTE.git
|
||||
cd civicstack
|
||||
cd ~
|
||||
git clone https://git.jackhlevy.com/jack/PocketVeto.git pocketveto
|
||||
cd pocketveto
|
||||
```
|
||||
|
||||
If your Gitea repo is private, create a **deploy token** in Gitea:
|
||||
@@ -54,7 +54,7 @@ If your Gitea repo is private, create a **deploy token** in Gitea:
|
||||
Store credentials so `git pull` doesn't prompt:
|
||||
```bash
|
||||
# Using a personal access token stored in the URL
|
||||
git remote set-url origin https://YOUR_TOKEN@YOUR_GIT_REMOTE.git
|
||||
git remote set-url origin https://YOUR_TOKEN@git.jackhlevy.com/jack/PocketVeto.git
|
||||
```
|
||||
|
||||
Verify:
|
||||
@@ -70,7 +70,7 @@ SSH in and run:
|
||||
|
||||
```bash
|
||||
ssh user@YOUR_SERVER_IP
|
||||
cd /opt/civicstack
|
||||
cd ~/pocketveto
|
||||
|
||||
git pull origin main
|
||||
docker compose up --build -d
|
||||
@@ -80,20 +80,20 @@ That's it. Docker rebuilds only the images that changed (layer cache means uncha
|
||||
|
||||
**One-liner from your local machine:**
|
||||
```bash
|
||||
ssh user@YOUR_SERVER_IP "cd /opt/civicstack && git pull origin main && docker compose up --build -d"
|
||||
ssh user@YOUR_SERVER_IP "cd ~/pocketveto && git pull origin main && docker compose up --build -d"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Option B — Deploy script
|
||||
|
||||
Create `/opt/civicstack/deploy.sh` on the server:
|
||||
Create `~/pocketveto/deploy.sh` on the server:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cd /opt/civicstack
|
||||
cd ~/pocketveto
|
||||
|
||||
echo "==> Pulling latest code"
|
||||
git pull origin main
|
||||
@@ -106,12 +106,12 @@ docker compose ps
|
||||
```
|
||||
|
||||
```bash
|
||||
chmod +x /opt/civicstack/deploy.sh
|
||||
chmod +x ~/pocketveto/deploy.sh
|
||||
```
|
||||
|
||||
Now from your local machine:
|
||||
```bash
|
||||
ssh user@YOUR_SERVER_IP /opt/civicstack/deploy.sh
|
||||
ssh user@YOUR_SERVER_IP ~/pocketveto/deploy.sh
|
||||
```
|
||||
|
||||
---
|
||||
@@ -132,9 +132,9 @@ Create `/etc/webhook/hooks.json`:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "civicstack-deploy",
|
||||
"execute-command": "/opt/civicstack/deploy.sh",
|
||||
"command-working-directory": "/opt/civicstack",
|
||||
"id": "pocketveto-deploy",
|
||||
"execute-command": "~/pocketveto/deploy.sh",
|
||||
"command-working-directory": "~/pocketveto",
|
||||
"response-message": "Deploying...",
|
||||
"trigger-rule": {
|
||||
"match": {
|
||||
@@ -158,7 +158,7 @@ webhook -hooks /etc/webhook/hooks.json -port 9000 -verbose
|
||||
`/etc/systemd/system/webhook.service`:
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Webhook listener for civicstack deploys
|
||||
Description=Webhook listener for PocketVeto deploys
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
@@ -179,7 +179,7 @@ Expose port 9000 (or proxy it through nginx/Caddy at a path like `/hooks/`).
|
||||
### 5b. Add the webhook in Gitea
|
||||
|
||||
- Gitea → Repository → Settings → Webhooks → Add Webhook → Gitea
|
||||
- **Target URL:** `http://YOUR_SERVER_IP:9000/hooks/civicstack-deploy`
|
||||
- **Target URL:** `http://YOUR_SERVER_IP:9000/hooks/pocketveto-deploy`
|
||||
- **Secret:** same value as `your-webhook-secret` above
|
||||
- **Trigger:** Push events → branch `main`
|
||||
|
||||
@@ -193,10 +193,10 @@ After any update you can confirm what's running:
|
||||
|
||||
```bash
|
||||
# Check the git commit on the server
|
||||
ssh user@YOUR_SERVER_IP "cd /opt/civicstack && git log --oneline -3"
|
||||
ssh user@YOUR_SERVER_IP "cd ~/pocketveto && git log --oneline -3"
|
||||
|
||||
# Check container status
|
||||
ssh user@YOUR_SERVER_IP "cd /opt/civicstack && docker compose ps"
|
||||
ssh user@YOUR_SERVER_IP "cd ~/pocketveto && docker compose ps"
|
||||
|
||||
# Hit the health endpoint
|
||||
curl http://YOUR_SERVER_IP/api/health
|
||||
@@ -210,7 +210,7 @@ If a bad deploy goes out:
|
||||
|
||||
```bash
|
||||
ssh user@YOUR_SERVER_IP
|
||||
cd /opt/civicstack
|
||||
cd ~/pocketveto
|
||||
|
||||
# Roll back to the previous commit
|
||||
git revert HEAD --no-edit # preferred — creates a revert commit, keeps history clean
|
||||
@@ -230,10 +230,10 @@ docker compose up --build -d # if manual
|
||||
|
||||
```bash
|
||||
ssh user@YOUR_SERVER_IP
|
||||
nano /opt/civicstack/.env
|
||||
nano ~/pocketveto/.env
|
||||
|
||||
# Then restart only the affected services (usually api + worker)
|
||||
cd /opt/civicstack
|
||||
cd ~/pocketveto
|
||||
docker compose up -d --no-build api worker beat
|
||||
```
|
||||
|
||||
@@ -245,9 +245,9 @@ docker compose up -d --no-build api worker beat
|
||||
|
||||
| Goal | Command |
|
||||
|---|---|
|
||||
| Manual deploy | `ssh server "cd /opt/civicstack && git pull && docker compose up --build -d"` |
|
||||
| One-step deploy script | `ssh server /opt/civicstack/deploy.sh` |
|
||||
| Manual deploy | `ssh server "cd ~/pocketveto && git pull && docker compose up --build -d"` |
|
||||
| One-step deploy script | `ssh server ~/pocketveto/deploy.sh` |
|
||||
| Automated on push | Gitea webhook → webhook listener → `deploy.sh` |
|
||||
| Rollback | `git revert HEAD` + redeploy |
|
||||
| Update env only | Edit `.env` on server + `docker compose up -d --no-build api worker beat` |
|
||||
| Check what's running | `ssh server "cd /opt/civicstack && git log --oneline -1 && docker compose ps"` |
|
||||
| Check what's running | `ssh server "cd ~/pocketveto && git log --oneline -1 && docker compose ps"` |
|
||||
|
||||
@@ -6,7 +6,7 @@ services:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-congress}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-pocketveto}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./postgres/data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-congress} -d ${POSTGRES_DB:-pocketveto}"]
|
||||
interval: 5s
|
||||
@@ -18,7 +18,7 @@ services:
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
- ./redis/data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
@@ -105,10 +105,6 @@ services:
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
|
||||
networks:
|
||||
app_network:
|
||||
driver: bridge
|
||||
|
||||
Reference in New Issue
Block a user