Skip to content

Commit

Permalink
optimize docker release workflow (#55)
Browse files Browse the repository at this point in the history
* optimize release workflow

- use explicity the specified version
- combine the release process in a single job

* Also template and release a kubernetes manifest

* Rename script

---------

Co-authored-by: Marc Schöchlin <marc.schoechlin@uhurutec.com>
  • Loading branch information
scoopex and Marc Schöchlin authored Jan 14, 2025
1 parent b78f692 commit 52bc780
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 55 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
type: boolean

jobs:
build-pkg:
build-and-release:
name: CI-PKGs
runs-on: ubuntu-latest
steps:
Expand All @@ -26,28 +26,20 @@ jobs:
run: ./create_packages
- name: Test Package
run: sudo ./ci_test
- name: Build Docker Image
run: |
./create_docker build
# Publish release
- uses: ncipollo/release-action@v1
if: ${{ inputs.publish_steps }}
with:
artifacts: "zabbix-agent-extensions*.deb,zabbix-agent-extensions-*.rpm"
build-docker:
name: CI-Docker
runs-on: ubuntu-latest
environment: "Docker Upload"
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
artifacts: "zabbix-agent-extensions*.deb,zabbix-agent-extensions-*.rpm,zabbix-agent-daemonset-kubernetes-release.yaml"
- name: Login to Docker Hub
if: ${{ inputs.publish_steps }}
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
run: |
./create_docker build
- name: Publish docker images
if: ${{ inputs.publish_steps }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.deb
*.rpm
*.idea
zabbix-agent-daemonset-kubernetes-release.yaml
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
FROM zabbix/zabbix-agent:ubuntu-7.2-latest

ARG BUILD_DATE
ARG BUILD_VERSION

USER 0
ADD /docker-scripts /tmp/setup
RUN chmod 755 /tmp/setup/*.sh
RUN /tmp/setup/01_phase_base.sh

ADD zabbix-agent-extensions_*_all.deb /tmp/setup
ADD zabbix-agent-extensions_${BUILD_VERSION}_all.deb /tmp/setup
RUN /tmp/setup/04_install_agent_extensions.sh
RUN /tmp/setup/05_perform_upgrade.sh
RUN /tmp/setup/05_perform_upgrade_and_cleanup.sh

ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]

Expand Down
7 changes: 6 additions & 1 deletion create_docker
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ buildDocker(){
set -x
docker rmi ${IMAGE_NAME}:${VERSION}
set -e
docker build --progress plain --build-arg BUILD_DATE="$(date "+%Y-%m-%d")" -t ${IMAGE_NAME}:${VERSION} -f Dockerfile .
docker build --progress plain \
--build-arg BUILD_DATE="$(date "+%Y-%m-%d")" \
--build-arg BUILD_VERSION="$VERSION" \
-t ${IMAGE_NAME}:${VERSION} -f Dockerfile .
sed "~s,${IMAGE_REPO}/${IMAGE_NAME}:latest,${IMAGE_REPO}/${IMAGE_NAME}:${VERSION}," zabbix-agent-daemonset-kubernetes.yaml > \
zabbix-agent-daemonset-kubernetes-release.yaml
set +xe
}

Expand Down
3 changes: 2 additions & 1 deletion docker-scripts/04_install_agent_extensions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

set -xe
cd /tmp/setup
ls -l /tmp/setup
dpkg -i *.deb
dpkg -i "zabbix-agent-extensions_${BUILD_VERSION?The version of the extension}_all.deb"
sed -i '~s,/var/lib/zabbix/:/sbin/nologin,/var/lib/zabbix/:/bin/bash,' /etc/passwd
File renamed without changes.
8 changes: 4 additions & 4 deletions zabbix-agent-daemonset-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
labels:
name: zabbix-agent
spec:
# this toleration is to have the daemonset runnable on master nodes
# this toleration is to have the daemonset runnable also on master nodes
# tolerations:
# - key: node-role.kubernetes.io/master
# effect: NoSchedule
Expand All @@ -43,7 +43,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: ZBX_ACTIVESERVERS
- name: ZBX_SERVER_HOST
value: "zabbix-proxy"
- name: ZBX_PASSIVESERVERS
value: "127.0.0.1,zabbix-proxy"
Expand Down Expand Up @@ -77,5 +77,5 @@ metadata:
name: zabbix-agent-extensions-include
namespace: "infra-zabbix-agent"
data:
"zabbix-agent-extensions-include.conf": |
Include=/usr/share/zabbix-agent-extensions/include.d/*.conf
"zabbix-agent-extensions-include-extra.conf": |
# Extra

0 comments on commit 52bc780

Please sign in to comment.