From 0d972361c2b10315ebcf97e1e133c7459ca3ceea Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Tue, 8 Sep 2020 00:16:26 +0300 Subject: [PATCH 1/2] Autobuild initial test --- .github/workflows/CI.yml | 115 +++++++++++++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 17 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9c4328d86..3309daa60 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,13 +55,37 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Install buildx + env: + DOCKER_CLI_EXPERIMENTAL: enabled + run: | + BUILDX_VERSION="0.4.2" + QEMU_TAG="latest" + mkdir -p ~/.docker/cli-plugins/ + curl -L https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64 \ + -o ~/.docker/cli-plugins/docker-buildx + chmod +x ~/.docker/cli-plugins/docker-buildx + docker pull -q multiarch/qemu-user-static:latest + docker run --rm --privileged multiarch/qemu-user-static:${QEMU_TAG} --reset -p yes --credential yes + docker buildx create --name builder-${GITHUB_SHA::8} --driver docker-container --use + docker buildx inspect --bootstrap + docker info + docker buildx inspect + + - name: Available platforms + run: docker buildx inspect | grep Platforms + - name: Prepare platform list id: platform run: | - DOCKER_PLATFORM="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le" + DOCKER_PLATFORM="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le" if [ "${{ matrix.os }}" == "ubuntu" ]; then - DOCKER_PLATFORM="linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le" + DOCKER_PLATFORM="linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le" + fi + + if [ "${{ matrix.os }}" == "ubuntu" ] && [ "${{ matrix.build }}" == "snmptraps" ]; then + DOCKER_PLATFORM="linux/amd64,linux/arm64" fi if [ "${{ matrix.os }}" == "centos" ]; then @@ -75,43 +99,46 @@ jobs: echo ::set-output name=list::${DOCKER_PLATFORM} - - name: Prepare environment + - name: Prepare environment (push) if: github.event_name == 'push' id: prepare_push run: | + TAGS_ARRAY=() + IMAGE_NAME="${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}" GIT_BRANCH="${{ github.ref }}" GIT_BRANCH=${GIT_BRANCH:11} echo "::warning Branch - ${GIT_BRANCH}" - TAGS="--tag $IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}" + TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}") if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then - TAGS="$TAGS --tag $IMAGE_NAME:latest" + TAGS_ARRAY+=("$IMAGE_NAME:latest") fi if [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then - TAGS="$TAGS --tag $IMAGE_NAME:${{ matrix.os }}-latest" + TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-latest") fi - if [ "${GIT_BRANCH}" == "trunk" ]; then - TAGS="--tag $IMAGE_NAME:${{ matrix.os }}-trunk" - fi + TAGS=$(printf -- "--tag %s " "${TAGS_ARRAY[@]}") echo "::warning Tags - ${TAGS}" echo ::set-output name=image_name::${IMAGE_NAME} + echo ::set-output name=image_tag_versions::$(printf -- "|%s" "${TAGS_ARRAY[@]}") echo ::set-output name=buildx_args::--platform "${{ steps.platform.outputs.list }}" \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VCS_REF=${GITHUB_SHA::8} \ ${TAGS} \ --file ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile ./${{ matrix.build }}/${{ matrix.os }} - - name: Prepare environment + - name: Prepare environment (release) if: github.event_name == 'release' && github.event.action == 'created' id: prepare_release run: | + TAGS_ARRAY=() + IMAGE_NAME="${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}" RELEASE_VERSION="${{ github.ref }}" RELEASE_VERSION=${RELEASE_VERSION:10} @@ -119,21 +146,75 @@ jobs: echo "::warning Release version ${RELEASE_VERSION}. Branch ${GIT_BRANCH}" - TAGS="$TAGS --tag $IMAGE_NAME:${{ matrix.os }}-${RELEASE_VERSION}" + TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${RELEASE_VERSION}") if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then - TAGS="$TAGS --tag $IMAGE_NAME:latest" + TAGS_ARRAY+=("$IMAGE_NAME:latest") fi + TAGS=$(printf -- "--tag %s " "${TAGS_ARRAY[@]}") + echo ::set-output name=image_name::${IMAGE_NAME} - echo ::set-output name=image_tag_version::${IMAGE_TAG_VERSION} + echo ::set-output name=image_tag_versions::$(printf -- "|%s" "${TAGS_ARRAY[@]}") echo ::set-output name=buildx_args::--platform "${{ steps.platform.outputs.list }}" \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VCS_REF=${GITHUB_SHA::8} \ - ${TAGS} \ + $TAGS \ --file ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile ./${{ matrix.build }}/${{ matrix.os }} - - name: Prepare environment output + - name: Build images + env: + DOCKER_CLI_EXPERIMENTAL: enabled run: | - echo "::warning ${{ steps.prepare_push.outputs.buildx_args }}" - echo "::warning ${{ steps.prepare_release.outputs.buildx_args }}" + if [ ! -z "${{ steps.prepare_push.outputs.buildx_args }}" ]; then + BUILDX_ARGS="${{ steps.prepare_push.outputs.buildx_args }}" + elif [ ! -z "${{ steps.prepare_release.outputs.buildx_args }}" ]; then + BUILDX_ARGS="${{ steps.prepare_release.outputs.buildx_args }}" + fi + + docker buildx build --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --output "type=image,push=false" \ + ${BUILDX_ARGS} + + - name: Docker Hub login + if: success() + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push images from cache + if: success() + env: + DOCKER_CLI_EXPERIMENTAL: enabled + run: | + if [ ! -z "${{ steps.prepare_push.outputs.buildx_args }}" ]; then + BUILDX_ARGS="${{ steps.prepare_push.outputs.buildx_args }}" + elif [ ! -z "${{ steps.prepare_release.outputs.buildx_args }}" ]; then + BUILDX_ARGS="${{ steps.prepare_release.outputs.buildx_args }}" + fi + + docker buildx build --cache-from "type=local,src=/tmp/.buildx-cache" \ + --output "type=image,push=false" \ + ${BUILDX_ARGS} + + - name: Inspect images + run: | + echo "::warning push - ${{ steps.prepare_push.outputs.buildx_args }}" + echo "::warning release - ${{ steps.prepare_release.outputs.buildx_args }}" + + if [ ! -z "${{ steps.prepare_push.outputs.image_tag_versions }}" ]; then + IMAGE_TAG_VERSIONS="${{ steps.prepare_push.outputs.image_tag_versions }}" + echo "::warning tags push raw - $IMAGE_TAG_VERSIONS" + elif [ ! -z "${{ steps.prepare_release.outputs.image_tag_versions }}" ]; then + IMAGE_TAG_VERSIONS="${{ steps.prepare_release.outputs.image_tag_versions }}" + echo "::warning tags release raw - $IMAGE_TAG_VERSIONS" + fi + + IMAGE_TAG_VERSIONS=${IMAGE_TAG_VERSIONS%%+(|)} + IFS='|' read -r -a IMAGE_TAG_VERSIONS <<< $IMAGE_TAG_VERSIONS + + for version in ${IMAGE_TAG_VERSIONS[@]}; do + echo "Checking \"$version\"... " + docker buildx imagetools inspect $version + done \ No newline at end of file From 1fdd3c98d9c8274fe448cf5fb9eb15f2ae7df1c3 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Tue, 8 Sep 2020 00:22:24 +0300 Subject: [PATCH 2/2] Use EPEL to install fping instead of custom package (CentOS) --- proxy-mysql/centos/Dockerfile | 3 ++- proxy-sqlite3/centos/Dockerfile | 3 ++- server-mysql/centos/Dockerfile | 5 +++-- server-pgsql/centos/Dockerfile | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/proxy-mysql/centos/Dockerfile b/proxy-mysql/centos/Dockerfile index 7f699bbd8..780ffec07 100644 --- a/proxy-mysql/centos/Dockerfile +++ b/proxy-mysql/centos/Dockerfile @@ -31,8 +31,9 @@ RUN set -eux && \ mkdir -p /usr/lib/zabbix/externalscripts && \ mkdir -p /usr/share/doc/zabbix-proxy-mysql && \ yum --quiet makecache && \ - yum -y install https://repo.zabbix.com/non-supported/rhel/7/x86_64/fping-3.10-1.el7.x86_64.rpm --setopt=tsflags=nodocs && \ + yum -y install epel-release && \ yum -y install --setopt=tsflags=nodocs \ + fping libcurl \ libxml2 \ mariadb \ diff --git a/proxy-sqlite3/centos/Dockerfile b/proxy-sqlite3/centos/Dockerfile index 544252e4c..76b2b701d 100644 --- a/proxy-sqlite3/centos/Dockerfile +++ b/proxy-sqlite3/centos/Dockerfile @@ -31,8 +31,9 @@ RUN set -eux && \ mkdir -p /usr/lib/zabbix/externalscripts && \ mkdir -p /usr/share/doc/zabbix-proxy-sqlite3 && \ yum --quiet makecache && \ - yum -y install https://repo.zabbix.com/non-supported/rhel/7/x86_64/fping-3.10-1.el7.x86_64.rpm --setopt=tsflags=nodocs && \ + yum -y install epel-release && \ yum -y install --setopt=tsflags=nodocs \ + fping \ libcurl \ libxml2 \ net-snmp-libs \ diff --git a/server-mysql/centos/Dockerfile b/server-mysql/centos/Dockerfile index 5739c3968..125ec3a1d 100644 --- a/server-mysql/centos/Dockerfile +++ b/server-mysql/centos/Dockerfile @@ -33,9 +33,10 @@ RUN set -eux && \ mkdir -p /usr/lib/zabbix/externalscripts && \ mkdir -p /usr/share/doc/zabbix-server-mysql && \ yum --quiet makecache && \ - yum -y install --setopt=tsflags=nodocs https://repo.zabbix.com/non-supported/rhel/7/x86_64/iksemel-1.4-2.el7.centos.x86_64.rpm \ - https://repo.zabbix.com/non-supported/rhel/7/x86_64/fping-3.10-1.el7.x86_64.rpm && \ + yum -y install --setopt=tsflags=nodocs https://repo.zabbix.com/non-supported/rhel/7/x86_64/iksemel-1.4-2.el7.centos.x86_64.rpm && \ + yum -y install epel-release && \ yum -y install --setopt=tsflags=nodocs \ + fping \ tzdata \ iputils \ traceroute \ diff --git a/server-pgsql/centos/Dockerfile b/server-pgsql/centos/Dockerfile index 26f073de6..60ff46c32 100644 --- a/server-pgsql/centos/Dockerfile +++ b/server-pgsql/centos/Dockerfile @@ -33,9 +33,10 @@ RUN set -eux && \ mkdir -p /usr/lib/zabbix/externalscripts && \ mkdir -p /usr/share/doc/zabbix-server-postgresql && \ yum --quiet makecache && \ - yum -y install --setopt=tsflags=nodocs https://repo.zabbix.com/non-supported/rhel/7/x86_64/iksemel-1.4-2.el7.centos.x86_64.rpm \ - https://repo.zabbix.com/non-supported/rhel/7/x86_64/fping-3.10-1.el7.x86_64.rpm && \ + yum -y install --setopt=tsflags=nodocs https://repo.zabbix.com/non-supported/rhel/7/x86_64/iksemel-1.4-2.el7.centos.x86_64.rpm && \ + yum -y install epel-release && \ yum -y install --setopt=tsflags=nodocs \ + fping \ iputils \ tzdata \ traceroute \