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