Skip to content

Commit c6be92e

Browse files
committed
chore: use external Redis in production
1 parent ff71cac commit c6be92e

6 files changed

Lines changed: 14 additions & 27 deletions

File tree

‎AGENTS.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ The Markdown body is rendered on episode detail pages.
7979
- Keep admin APIs under `/api/admin/*` protected by `getAdminFromContext`.
8080
- Keep Redis as a defensive/cache layer only. Markdown files remain the content
8181
source of truth.
82+
- Keep production Redis external. Local Compose may start Redis for development,
83+
but production Compose must consume `REDIS_URL` from the private server
84+
environment instead of creating a Redis service.
8285
- Public GET/HEAD pages should keep short cache headers and query stripping so
8386
random query parameters do not bypass caches.
8487
- Keep staging safe for search engines: `PUBLIC_ALLOW_INDEXING=false` until the

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,16 @@ Check the production-style Compose config with explicit placeholder values:
104104
```bash
105105
JWT_SECRET=dev-secret \
106106
ADMIN_PASSWORD=dev-password \
107-
REDIS_PASSWORD=dev-redis-password \
108-
REDIS_URL=redis://:dev-redis-password@redis:6379 \
107+
REDIS_URL=redis://:dev-redis-password@redis.example.internal:6379 \
109108
docker compose -f docker-compose.prod.yml config
110109
```
111110

112111
In Docker, mount the episode directory to `/app/content/episodes`.
113112

113+
Local Compose starts a Redis container for development. Production Compose does
114+
not create Redis; set `REDIS_URL` to an existing private Redis service in the
115+
server environment.
116+
114117
## Deployment
115118

116119
The deployment helper is intentionally parameterized. Pass your own SSH host,

‎TODO.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pnpm audit --audit-level moderate
3939
docker compose config
4040
JWT_SECRET=dev-secret \
4141
ADMIN_PASSWORD=dev-password \
42-
REDIS_PASSWORD=dev-redis-password \
43-
REDIS_URL=redis://:dev-redis-password@redis:6379 \
42+
REDIS_URL=redis://:dev-redis-password@redis.example.internal:6379 \
4443
docker compose -f docker-compose.prod.yml config
4544
```

‎docker-compose.prod.yml‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
name: webworker-tech-new
22

33
services:
4-
redis:
5-
image: ${REDIS_IMAGE:-redis:7.0.15}
6-
restart: unless-stopped
7-
command: ["sh", "-c", "redis-server --requirepass \"$$REDIS_PASSWORD\""]
8-
environment:
9-
REDIS_PASSWORD: ${REDIS_PASSWORD:?REDIS_PASSWORD is required}
10-
volumes:
11-
- redis_data:/data
12-
healthcheck:
13-
test: ["CMD-SHELL", "REDISCLI_AUTH=\"$$REDIS_PASSWORD\" redis-cli ping"]
14-
interval: 10s
15-
timeout: 5s
16-
retries: 12
17-
184
app:
195
image: ${IMAGE_NAME:-webworker-tech:ssr-amd64}
206
restart: unless-stopped
@@ -41,9 +27,3 @@ services:
4127
interval: 30s
4228
timeout: 5s
4329
retries: 5
44-
depends_on:
45-
redis:
46-
condition: service_healthy
47-
48-
volumes:
49-
redis_data:

‎docs/staging-deploy.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ PUBLIC_ALLOW_INDEXING=false
4141
JWT_SECRET=<long-random-secret>
4242
ADMIN_USERNAME=admin
4343
ADMIN_PASSWORD=<strong-password>
44-
REDIS_PASSWORD=<strong-redis-password>
45-
REDIS_URL=redis://:<strong-redis-password>@redis:6379
44+
REDIS_URL=redis://:<strong-redis-password>@redis.example.internal:6379
4645
RSS_AUTO_SYNC=true
4746
RSS_AUTO_SYNC_INTERVAL_HOURS=24
4847
HOST_PORT=4322
@@ -53,6 +52,9 @@ IMAGE_NAME=webworker-tech:ssr-amd64
5352
Prefer `ADMIN_PASSWORD_SHA256` over `ADMIN_PASSWORD` when the runtime makes
5453
secret rotation manageable.
5554

55+
Production Compose expects Redis to be an existing private service. It does not
56+
start its own Redis container.
57+
5658
## Deploy
5759

5860
Pass private deployment details through environment variables:

‎scripts/deploy-new-webworker.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ssh "$REMOTE_HOST" "
5353
set -eu
5454
cd '$REMOTE_APP_DIR'
5555
docker load -i '$REMOTE_ROOT/$(basename "$TAR_PATH")'
56-
EPISODES_HOST_DIR='$REMOTE_CONTENT_DIR' IMAGE_NAME='$IMAGE_NAME' docker compose --env-file '$ENV_FILE' -f docker-compose.prod.yml up -d
56+
EPISODES_HOST_DIR='$REMOTE_CONTENT_DIR' IMAGE_NAME='$IMAGE_NAME' docker compose --env-file '$ENV_FILE' -f docker-compose.prod.yml up -d --remove-orphans
5757
for i in \$(seq 1 20); do
5858
if curl -fsS http://127.0.0.1:$REMOTE_HOST_PORT/api/health >/dev/null 2>&1; then
5959
exit 0

0 commit comments

Comments
 (0)