rewrite v5 of woodpecker.yml

This commit is contained in:
Josh 2025-07-30 19:59:57 +00:00
parent 632cb6eba5
commit c40882ee59

View File

@ -1,49 +1,41 @@
# .woodpecker.yml dev1 ➜ aptivastaging
kind: pipeline kind: pipeline
type: docker type: docker
name: build-and-deploy name: build-and-deploy
workspace: workspace:
base: /woodpecker base: /woodpecker
path: src # repo will be /woodpecker/src path: src
clone: clone:
depth: 50 depth: 50
############################################################
# 1. Build & push the four images to Artifact Registry
############################################################
steps: steps:
# ─── build & push ──────────────────────────────────────────
- name: build-and-push - name: build-and-push
image: docker:24.0-cli # uses hosts Docker socket image: docker:24.0-cli # only the CLI, we reuse host docker
privileged: true # required for buildx privileged: true
volumes: volumes:
- name: docker-sock # mount the host socket - name: docker-sock # mount declared at bottom
path: /var/run/docker.sock path: /var/run/docker.sock
commands: | commands:
set -euo pipefail - |
set -e
REG=us-central1-docker.pkg.dev/aptivaai-dev/aptiva-repo REG=us-central1-docker.pkg.dev/aptivaai-dev/aptiva-repo
TAG=$(echo "$CI_COMMIT_SHA" | head -c 8) TAG=$(echo "$CI_COMMIT_SHA" | head -c 8)
docker buildx create --use --name woodpecker || true docker buildx create --use --name woodpecker || true
for svc in server1 server2 server3 nginx ; do for svc in server1 server2 server3 nginx ; do
docker buildx build \ docker buildx build -f Dockerfile.${svc} \
--file Dockerfile.${svc} \ -t ${REG}/${svc}:${TAG} --push .
--tag ${REG}/${svc}:${TAG} \
--push .
done done
when: when:
event: [push, manual] event: [push, manual]
branch: [master] branch: [master]
############################################################ # ─── deploy staging ────────────────────────────────────────
# 2. Rolling update on the *staging* VM
############################################################
- name: deploy-staging - name: deploy-staging
image: appleboy/drone-ssh image: appleboy/drone-ssh
settings: settings:
host: 10.128.0.12 # internal IP of aptivastaging host: 10.128.0.12
port: 22 port: 22
username: jcoakley username: jcoakley
key: key:
@ -52,7 +44,7 @@ steps:
from_secret: STAGING_KNOWN_HOSTS from_secret: STAGING_KNOWN_HOSTS
script: script:
- cd /opt/aptiva-staging-app - cd /opt/aptiva-staging-app
- ./refresh_secrets.sh # pulls latest SecretManager values - ./refresh_secrets.sh
- TAG=$(echo "$CI_COMMIT_SHA" | head -c 8) - TAG=$(echo "$CI_COMMIT_SHA" | head -c 8)
- IMG_TAG=$TAG docker compose pull - IMG_TAG=$TAG docker compose pull
- IMG_TAG=$TAG docker compose up -d --remove-orphans - IMG_TAG=$TAG docker compose up -d --remove-orphans
@ -60,9 +52,7 @@ steps:
event: [push, manual] event: [push, manual]
branch: [master] branch: [master]
############################################################ # ─── global volume declaration (list **not** indented) ─────
# 3. Volumes (declared once, referenced by name)
############################################################
volumes: volumes:
- name: docker-sock - name: docker-sock
host: host: