44 lines
1.9 KiB
YAML
44 lines
1.9 KiB
YAML
# Woodpecker CI - Build Pipeline (runs on main branch pushes)
|
|
|
|
steps:
|
|
build-images:
|
|
image: docker:24-dind
|
|
commands:
|
|
- echo "=== Building Docker images ==="
|
|
- docker build -t sysmonstm/aggregator:${CI_COMMIT_SHA:0:7} -f services/aggregator/Dockerfile --target production .
|
|
- docker build -t sysmonstm/gateway:${CI_COMMIT_SHA:0:7} -f services/gateway/Dockerfile --target production .
|
|
- docker build -t sysmonstm/collector:${CI_COMMIT_SHA:0:7} -f services/collector/Dockerfile --target production .
|
|
- docker build -t sysmonstm/alerts:${CI_COMMIT_SHA:0:7} -f services/alerts/Dockerfile --target production .
|
|
- echo "=== Tagging as latest ==="
|
|
- docker tag sysmonstm/aggregator:${CI_COMMIT_SHA:0:7} sysmonstm/aggregator:latest
|
|
- docker tag sysmonstm/gateway:${CI_COMMIT_SHA:0:7} sysmonstm/gateway:latest
|
|
- docker tag sysmonstm/collector:${CI_COMMIT_SHA:0:7} sysmonstm/collector:latest
|
|
- docker tag sysmonstm/alerts:${CI_COMMIT_SHA:0:7} sysmonstm/alerts:latest
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
|
|
push-to-registry:
|
|
image: docker:24-dind
|
|
commands:
|
|
- echo "=== Logging into registry ==="
|
|
- echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin "$REGISTRY_URL"
|
|
- echo "=== Pushing images ==="
|
|
- |
|
|
for svc in aggregator gateway collector alerts; do
|
|
docker tag sysmonstm/$svc:${CI_COMMIT_SHA:0:7} $REGISTRY_URL/sysmonstm/$svc:${CI_COMMIT_SHA:0:7}
|
|
docker tag sysmonstm/$svc:latest $REGISTRY_URL/sysmonstm/$svc:latest
|
|
docker push $REGISTRY_URL/sysmonstm/$svc:${CI_COMMIT_SHA:0:7}
|
|
docker push $REGISTRY_URL/sysmonstm/$svc:latest
|
|
echo "Pushed $svc"
|
|
done
|
|
secrets: [registry_user, registry_password, registry_url]
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
|
|
depends_on:
|
|
- test
|
|
|
|
when:
|
|
event: push
|
|
branch: main
|