build pipeline v0
This commit is contained in:
parent
2eb2596011
commit
d2357199b5
@ -1,56 +1,19 @@
|
|||||||
---
|
---
|
||||||
steps:
|
steps:
|
||||||
# ── 1. Build & push images ──────────────────────────────
|
|
||||||
- name: build-and-push
|
|
||||||
image: docker:24.0-cli
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: docker-sock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
environment:
|
|
||||||
REG: us-central1-docker.pkg.dev/aptivaai-dev/aptiva-repo
|
|
||||||
commands:
|
|
||||||
- |
|
|
||||||
set -eu
|
|
||||||
TAG=$(echo "$CI_COMMIT_SHA" | head -c 8)
|
|
||||||
docker buildx create --use --name woodpecker || true
|
|
||||||
for svc in server1 server2 server3 nginx; do
|
|
||||||
docker buildx build -f Dockerfile.${svc} \
|
|
||||||
-t ${REG}/${svc}:${TAG} --push .
|
|
||||||
done
|
|
||||||
when:
|
|
||||||
event: [push, manual]
|
|
||||||
branch: [master]
|
|
||||||
|
|
||||||
# ── 2. Deploy to staging (runtime GCP secret injection) ──
|
|
||||||
- name: deploy-staging
|
- name: deploy-staging
|
||||||
image: gcr.io/google.com/cloudsdktool/cloud-sdk:latest
|
image: gcr.io/google.com/cloudsdktool/cloud-sdk:latest
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
set -eu
|
set -eu
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
|
|
||||||
# 🔐 Pull and decode known_hosts
|
|
||||||
gcloud secrets versions access latest --secret="KNOWN_HOSTS_B64" --project="aptivaai-dev" | base64 -d > ~/.ssh/known_hosts
|
gcloud secrets versions access latest --secret="KNOWN_HOSTS_B64" --project="aptivaai-dev" | base64 -d > ~/.ssh/known_hosts
|
||||||
chmod 644 ~/.ssh/known_hosts
|
chmod 644 ~/.ssh/known_hosts
|
||||||
|
|
||||||
# 🔐 Pull and decode SSH private key
|
|
||||||
gcloud secrets versions access latest --secret="STAGING_SSH_KEY_B64" --project="aptivaai-dev" | base64 -d > ~/.ssh/id_ed25519
|
gcloud secrets versions access latest --secret="STAGING_SSH_KEY_B64" --project="aptivaai-dev" | base64 -d > ~/.ssh/id_ed25519
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
|
||||||
# 🚀 Deploy via SSH
|
|
||||||
TAG=$(echo "$CI_COMMIT_SHA" | head -c 8)
|
|
||||||
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes jcoakley@10.128.0.12 <<EOF
|
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes jcoakley@10.128.0.12 <<EOF
|
||||||
set -eu
|
set -eu
|
||||||
cd /opt/aptiva-staging-app
|
cd /opt/aptiva-staging-app
|
||||||
IMG_TAG=$TAG docker compose pull
|
IMG_TAG=$(echo "$CI_COMMIT_SHA" | head -c 8)
|
||||||
IMG_TAG=$TAG docker compose up -d --force-recreate --remove-orphans
|
IMG_TAG=$IMG_TAG docker compose pull
|
||||||
|
IMG_TAG=$IMG_TAG docker compose up -d --force-recreate --remove-orphans
|
||||||
EOF
|
EOF
|
||||||
when:
|
|
||||||
event: [push, manual]
|
|
||||||
branch: [master]
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: docker-sock
|
|
||||||
host:
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
|
Loading…
Reference in New Issue
Block a user