Commit 60ccbeaa authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Add deploy_dev CI job, auto-deploying every dev push to the dev server

Mirrors deploy_prod's exact logic (same deploy.sh, same bootstrap-or-
update behavior) but SSHes in as the unprivileged ubuntu user and wraps
the actual deploy.sh invocation in sudo, rather than logging in as root
directly - no new root SSH access on the dev box. No secrets passed:
the dev box's .env/database were seeded once by hand during bootstrap,
and deploy.sh only rewrites .env when secrets are actually supplied.

Needs DEV_SERVER_IP and DEV_SSH_PRIVATE_KEY as CI/CD variables.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 17b5753b
Pipeline #1313 failed with stages
......@@ -90,3 +90,37 @@ deploy_prod:
bash /root/stax_deploy_bootstrap.sh"
only:
- main
# Runs on every push to dev, after test passes. Same deploy.sh as deploy_prod above, same
# bootstrap-or-update logic - only the target box and how we get root on it differ:
# - deploy_prod SSHes straight in as root (its own long-standing setup, unchanged here).
# - deploy_dev SSHes in as the unprivileged `ubuntu` user instead and wraps the actual
# deploy.sh invocation in `sudo` - no root login is ever exposed on the dev box, root access
# only exists transiently for the duration of this one command, via sudo access that's
# already configured there (not something this pipeline grants).
# No STAX_DEV_* secrets are passed here on purpose: the dev box's .env/database were seeded
# once by hand during initial bootstrap, and deploy.sh only (re)writes .env when secrets are
# actually supplied - omitting them here means every future run just leaves the existing
# working .env alone, so this job genuinely needs nothing beyond SSH access to work.
deploy_dev:
stage: deploy
image: python:3.10-slim
variables:
STAX_DEPLOY_DIR: "/root/stax_backend_api"
before_script:
- apt-get update -qq && apt-get install -y -qq --no-install-recommends openssh-client
- echo "$DEV_SSH_PRIVATE_KEY" > /tmp/dev_deploy_key
- chmod 600 /tmp/dev_deploy_key
- ssh-keyscan -p "${DEV_SSH_PORT:-22}" "$DEV_SERVER_IP" > /tmp/known_hosts 2>/dev/null || true
script:
- echo "Deploying $CI_COMMIT_SHORT_SHA to dev..."
- >
scp -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/tmp/known_hosts -i /tmp/dev_deploy_key -P "${DEV_SSH_PORT:-22}"
deploy/scripts/deploy.sh ubuntu@"$DEV_SERVER_IP":/tmp/stax_dev_deploy_bootstrap.sh
- >
ssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/tmp/known_hosts -i /tmp/dev_deploy_key -p "${DEV_SSH_PORT:-22}"
ubuntu@"$DEV_SERVER_IP"
"sudo env STAX_DEPLOY_DIR='${STAX_DEPLOY_DIR}' STAX_DEPLOY_REF=origin/dev
bash /tmp/stax_dev_deploy_bootstrap.sh"
only:
- dev
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment