dev1/.woodpecker.yml

70 lines
2.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# .woodpecker.yml dev1 ➜ aptivastaging
kind: pipeline
type: docker
name: build-and-deploy
workspace:
base: /woodpecker
path: src # repo will be /woodpecker/src
clone:
depth: 50
############################################################
# 1. Build & push the four images to Artifact Registry
############################################################
steps:
- name: build-and-push
image: docker:24.0-cli # uses hosts Docker socket
privileged: true # required for buildx
volumes:
- name: docker-sock # mount the host socket
path: /var/run/docker.sock
commands: |
set -euo pipefail
REG=us-central1-docker.pkg.dev/aptivaai-dev/aptiva-repo
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 \
--file Dockerfile.${svc} \
--tag ${REG}/${svc}:${TAG} \
--push .
done
when:
event: [push, manual]
branch: [master]
############################################################
# 2. Rolling update on the *staging* VM
############################################################
- name: deploy-staging
image: appleboy/drone-ssh
settings:
host: 10.128.0.12 # internal IP of aptivastaging
port: 22
username: jcoakley
key:
from_secret: STAGING_SSH_KEY
known_hosts:
from_secret: STAGING_KNOWN_HOSTS
script:
- cd /opt/aptiva-staging-app
- ./refresh_secrets.sh # pulls latest SecretManager values
- TAG=$(echo "$CI_COMMIT_SHA" | head -c 8)
- IMG_TAG=$TAG docker compose pull
- IMG_TAG=$TAG docker compose up -d --remove-orphans
when:
event: [push, manual]
branch: [master]
############################################################
# 3. Volumes (declared once, referenced by name)
############################################################
volumes:
- name: docker-sock
host:
path: /var/run/docker.sock