48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
kind: pipeline
|
|
type: docker
|
|
name: build-host-redirect-image
|
|
|
|
steps:
|
|
- name: build-and-tag-host-image
|
|
image: docker:cli
|
|
volumes:
|
|
- name: dockersock
|
|
path: /var/run/docker.sock
|
|
commands:
|
|
- echo "Building redirect image on host Docker daemon..."
|
|
# --pull ensures base image vulnerabilities/patches are pulled on weekly cron builds
|
|
- docker build --pull -t redirect:latest .
|
|
- |
|
|
if [ -n "$DRONE_COMMIT_SHA" ]; then
|
|
SHORT_SHA=$(echo $DRONE_COMMIT_SHA | cut -c1-7)
|
|
docker tag redirect:latest redirect:$SHORT_SHA
|
|
echo "Tagged redirect:$SHORT_SHA"
|
|
fi
|
|
- |
|
|
if [ -n "$DRONE_TAG" ]; then
|
|
docker tag redirect:latest redirect:$DRONE_TAG
|
|
echo "Tagged redirect:$DRONE_TAG"
|
|
fi
|
|
- |
|
|
# Fetch latest git tag to update the latest release tag (e.g., on weekly cron builds)
|
|
apk add --no-cache git 2>/dev/null || true
|
|
git fetch --tags 2>/dev/null || true
|
|
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || true)
|
|
if [ -n "$LATEST_TAG" ]; then
|
|
docker tag redirect:latest redirect:$LATEST_TAG
|
|
echo "Tagged latest release tag: redirect:$LATEST_TAG"
|
|
fi
|
|
- echo "Build complete. Images registered on host Docker engine:"
|
|
- docker images | grep redirect || true
|
|
|
|
volumes:
|
|
- name: dockersock
|
|
host:
|
|
path: /var/run/docker.sock
|
|
|
|
trigger:
|
|
event:
|
|
- push
|
|
- tag
|
|
- cron
|