feat: parameterize staging compose configuration

This commit is contained in:
Jesse_Chen
2026-07-20 15:55:59 +08:00
parent abe4e197b8
commit 92a1ea1db1
3 changed files with 29 additions and 5 deletions
+4
View File
@@ -0,0 +1,4 @@
{$SITE_ADDRESS:https://staging.jyotisha.chat} {
encode zstd gzip
reverse_proxy web:3000
}
+5 -3
View File
@@ -4,7 +4,8 @@ services:
context: ..
dockerfile: deploy/railway-api.Dockerfile
restart: unless-stopped
env_file: ../.env.production
env_file:
- ${APP_ENV_FILE:-../.env.production}
environment:
PORT: 5200
JYOTISH_ALLOWED_HOSTS: localhost,127.0.0.1,::1,api
@@ -24,7 +25,8 @@ services:
NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${NEXT_PUBLIC_SUPABASE_ANON_KEY}
restart: unless-stopped
env_file: ../.env.production
env_file:
- ${APP_ENV_FILE:-../.env.production}
environment:
GITHUB_SHA: ${GITHUB_SHA}
PORT: 3000
@@ -45,7 +47,7 @@ services:
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- ${CADDYFILE_PATH:-./Caddyfile}:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
+20 -2
View File
@@ -11,12 +11,14 @@ test("health endpoint exposes deployment identity for production verification",
assert.match(source, /gitCommit/);
});
test("production deployment passes the tested revision into the web runtime", () => {
test("manual production deployment passes the selected revision into the web runtime", () => {
const compose = readFileSync(new URL("../../deploy/docker-compose.server.yml", import.meta.url), "utf8");
const workflow = readFileSync(new URL("../../.github/workflows/deploy-production.yml", import.meta.url), "utf8");
assert.match(compose, /GITHUB_SHA: \$\{GITHUB_SHA\}/);
assert.match(workflow, /DEPLOY_GIT_SHA: \$\{\{ github\.event\.workflow_run\.head_sha \|\| github\.sha \}\}/);
assert.match(workflow, /workflow_dispatch:/);
assert.doesNotMatch(workflow, /workflow_run:/);
assert.match(workflow, /DEPLOY_GIT_SHA: \$\{\{ github\.sha \}\}/);
assert.match(workflow, /GITHUB_SHA='\$DEPLOY_GIT_SHA'/);
assert.match(workflow, /get\("deployment", \{\}\)\.get\("gitCommit"/);
assert.match(workflow, /DEPLOY_GIT_SHA/);
@@ -24,3 +26,19 @@ test("production deployment passes the tested revision into the web runtime", ()
assert.match(workflow, /git ls-remote origin refs\/heads\/main/);
assert.match(workflow, /steps\.revision\.outputs\.deploy == 'true'/);
});
test("server compose accepts staging paths while preserving production defaults", () => {
const compose = readFileSync(new URL("../../deploy/docker-compose.server.yml", import.meta.url), "utf8");
assert.match(compose, /env_file:\s*\n\s*- \$\{APP_ENV_FILE:-\.\.\/\.env\.production\}/);
assert.match(compose, /\$\{CADDYFILE_PATH:-\.\/Caddyfile\}:\/etc\/caddy\/Caddyfile:ro/);
assert.match(compose, /SITE_ADDRESS: \$\{SITE_ADDRESS:-https:\/\/jyotisha\.chat\}/);
});
test("staging Caddy configuration serves only the configured staging address", () => {
const caddy = readFileSync(new URL("../../deploy/Caddyfile.staging", import.meta.url), "utf8");
assert.match(caddy, /\{\$SITE_ADDRESS:https:\/\/staging\.jyotisha\.chat\}/);
assert.match(caddy, /reverse_proxy web:3000/);
assert.doesNotMatch(caddy, /www\.jyotisha\.chat/);
});