mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-01-17 19:19:07 +01:00
Preparation for multistage builds
This commit is contained in:
parent
6e9b89982a
commit
3497c2d7d6
1
.github/workflows/Azure.yml
vendored
1
.github/workflows/Azure.yml
vendored
@ -8,7 +8,6 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- '5.0'
|
- '5.0'
|
||||||
- '5.4'
|
- '5.4'
|
||||||
- 'trunk'
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.env*'
|
- '.env*'
|
||||||
- 'docker-compose*.yaml'
|
- 'docker-compose*.yaml'
|
||||||
|
191
.github/workflows/CI.yml
vendored
191
.github/workflows/CI.yml
vendored
@ -1,191 +0,0 @@
|
|||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '4.0'
|
|
||||||
- '5.0'
|
|
||||||
- '5.2'
|
|
||||||
- '5.4'
|
|
||||||
- 'trunk'
|
|
||||||
paths-ignore:
|
|
||||||
- '.env*'
|
|
||||||
- 'docker-compose*.yaml'
|
|
||||||
- '*/rhel/*'
|
|
||||||
- '*/windows/*'
|
|
||||||
- "**.md"
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
timeout-minutes: 70
|
|
||||||
env:
|
|
||||||
LATEST_BRANCH: "${{ github.event.repository.default_branch }}"
|
|
||||||
DOCKER_REPOSITORY: "zabbix"
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
build:
|
|
||||||
- agent
|
|
||||||
- agent2
|
|
||||||
- java-gateway
|
|
||||||
- proxy-mysql
|
|
||||||
- proxy-sqlite3
|
|
||||||
- server-mysql
|
|
||||||
- server-pgsql
|
|
||||||
- snmptraps
|
|
||||||
- web-apache-mysql
|
|
||||||
- web-apache-pgsql
|
|
||||||
- web-nginx-mysql
|
|
||||||
- web-nginx-pgsql
|
|
||||||
- web-service
|
|
||||||
os:
|
|
||||||
- alpine
|
|
||||||
- ubuntu
|
|
||||||
- ol
|
|
||||||
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Prepare platform list
|
|
||||||
id: platform
|
|
||||||
run: |
|
|
||||||
DOCKER_PLATFORM="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x"
|
|
||||||
|
|
||||||
if [ "${{ matrix.build }}" == "agent2" ]; then
|
|
||||||
DOCKER_PLATFORM="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ matrix.build }}" == "web-service" ]; then
|
|
||||||
DOCKER_PLATFORM="linux/amd64,linux/arm64"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ matrix.os }}" == "ubuntu" ]; then
|
|
||||||
DOCKER_PLATFORM="linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ matrix.build }}" == "java-gateway" ]; then
|
|
||||||
DOCKER_PLATFORM=${DOCKER_PLATFORM%",linux/ppc64le"}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ matrix.build }}" == "web-service" ]; then
|
|
||||||
DOCKER_PLATFORM=${DOCKER_PLATFORM%",linux/ppc64le"}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ matrix.os }}" == "ol" ]; then
|
|
||||||
DOCKER_PLATFORM="linux/amd64,linux/arm64"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ::set-output name=list::${DOCKER_PLATFORM}
|
|
||||||
|
|
||||||
- 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 "::debug::Branch - ${GIT_BRANCH}"
|
|
||||||
|
|
||||||
if [ "${GIT_BRANCH}" == "trunk" ]; then
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}")
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}")
|
|
||||||
else
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}-latest")
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}-latest")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:latest")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-latest")
|
|
||||||
fi
|
|
||||||
|
|
||||||
TAGS=$(printf -- "%s, " "${TAGS_ARRAY[@]}")
|
|
||||||
|
|
||||||
echo "::debug::Tags - ${TAGS}"
|
|
||||||
|
|
||||||
echo ::set-output name=image_name::${IMAGE_NAME}
|
|
||||||
echo ::set-output name=image_tag_versions::$(printf -- "%s," "${TAGS_ARRAY[@]}")
|
|
||||||
|
|
||||||
- name: Prepare environment (release)
|
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
|
||||||
id: prepare_release
|
|
||||||
run: |
|
|
||||||
TAGS_ARRAY=()
|
|
||||||
|
|
||||||
IMAGE_NAME="${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}"
|
|
||||||
RELEASE_VERSION="${{ github.ref }}"
|
|
||||||
RELEASE_VERSION=${RELEASE_VERSION:10}
|
|
||||||
GIT_BRANCH=${RELEASE_VERSION%.*}
|
|
||||||
|
|
||||||
echo "::debug::Release version ${RELEASE_VERSION}. Branch ${GIT_BRANCH}"
|
|
||||||
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${RELEASE_VERSION}")
|
|
||||||
TAGS_ARRAY+=("$IMAGE_NAME:${RELEASE_VERSION}-${{ matrix.os }}")
|
|
||||||
|
|
||||||
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
|
||||||
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_versions::$(printf -- ",%s" "${TAGS_ARRAY[@]}")
|
|
||||||
|
|
||||||
- name: Prepare tags
|
|
||||||
id: prepare_tags
|
|
||||||
run: |
|
|
||||||
if [ ! -z "${{ steps.prepare_push.outputs.image_tag_versions }}" ]; then
|
|
||||||
TAGS="${{ steps.prepare_push.outputs.image_tag_versions }}"
|
|
||||||
IMAGE_NAME="${{ steps.prepare_push.outputs.image_name }}"
|
|
||||||
elif [ ! -z "${{ steps.prepare_release.outputs.image_tag_versions }}" ]; then
|
|
||||||
TAGS="${{ steps.prepare_release.outputs.image_tag_versions }}"
|
|
||||||
IMAGE_NAME="${{ steps.prepare_release.outputs.image_name }}"
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ::set-output name=image_tag_versions::${TAGS}
|
|
||||||
echo ::set-output name=image_name::${IMAGE_NAME}
|
|
||||||
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: ./${{ matrix.build }}/${{ matrix.os }}
|
|
||||||
file: ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
|
||||||
platforms: ${{ steps.platform.outputs.list }}
|
|
||||||
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
|
||||||
tags: ${{ steps.prepare_tags.outputs.image_tag_versions }}
|
|
||||||
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
298
.github/workflows/build_images.yml
vendored
Normal file
298
.github/workflows/build_images.yml
vendored
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
name: Build images
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'trunk'
|
||||||
|
paths-ignore:
|
||||||
|
- '.env*'
|
||||||
|
- 'docker-compose*.yaml'
|
||||||
|
- '*/rhel/*'
|
||||||
|
- '*/windows/*'
|
||||||
|
- "**.md"
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_base:
|
||||||
|
timeout-minutes: 70
|
||||||
|
env:
|
||||||
|
LATEST_BRANCH: "${{ github.event.repository.default_branch }}"
|
||||||
|
DOCKER_REPOSITORY: "zabbix"
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
build:
|
||||||
|
- build-base
|
||||||
|
os:
|
||||||
|
- alpine
|
||||||
|
- ubuntu
|
||||||
|
- ol
|
||||||
|
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Prepare platform list
|
||||||
|
id: platform
|
||||||
|
run: |
|
||||||
|
DOCKER_PLATFORM="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x"
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "ubuntu" ]; then
|
||||||
|
DOCKER_PLATFORM="linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "ol" ]; then
|
||||||
|
DOCKER_PLATFORM="linux/amd64,linux/arm64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ::set-output name=list::${DOCKER_PLATFORM}
|
||||||
|
|
||||||
|
- 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 "::debug::Branch - ${GIT_BRANCH}"
|
||||||
|
|
||||||
|
if [ "${GIT_BRANCH}" == "trunk" ]; then
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}")
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}")
|
||||||
|
else
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}-latest")
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}-latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
TAGS=$(printf -- "%s, " "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
echo "::debug::Tags - ${TAGS}"
|
||||||
|
|
||||||
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
||||||
|
echo ::set-output name=image_tag_versions::$(printf -- "%s," "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
- name: Prepare environment (release)
|
||||||
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
|
id: prepare_release
|
||||||
|
run: |
|
||||||
|
TAGS_ARRAY=()
|
||||||
|
|
||||||
|
IMAGE_NAME="${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}"
|
||||||
|
RELEASE_VERSION="${{ github.ref }}"
|
||||||
|
RELEASE_VERSION=${RELEASE_VERSION:10}
|
||||||
|
GIT_BRANCH=${RELEASE_VERSION%.*}
|
||||||
|
|
||||||
|
echo "::debug::Release version ${RELEASE_VERSION}. Branch ${GIT_BRANCH}"
|
||||||
|
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${RELEASE_VERSION}")
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${RELEASE_VERSION}-${{ matrix.os }}")
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
||||||
|
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_versions::$(printf -- ",%s" "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
- name: Prepare tags
|
||||||
|
id: prepare_tags
|
||||||
|
run: |
|
||||||
|
if [ ! -z "${{ steps.prepare_push.outputs.image_tag_versions }}" ]; then
|
||||||
|
TAGS="${{ steps.prepare_push.outputs.image_tag_versions }}"
|
||||||
|
IMAGE_NAME="${{ steps.prepare_push.outputs.image_name }}"
|
||||||
|
elif [ ! -z "${{ steps.prepare_release.outputs.image_tag_versions }}" ]; then
|
||||||
|
TAGS="${{ steps.prepare_release.outputs.image_tag_versions }}"
|
||||||
|
IMAGE_NAME="${{ steps.prepare_release.outputs.image_name }}"
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ::set-output name=image_tag_versions::${TAGS}
|
||||||
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./${{ matrix.build }}/${{ matrix.os }}
|
||||||
|
file: ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
||||||
|
platforms: ${{ steps.platform.outputs.list }}
|
||||||
|
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
||||||
|
tags: ${{ steps.prepare_tags.outputs.image_tag_versions }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
||||||
|
build_base_database:
|
||||||
|
timeout-minutes: 70
|
||||||
|
env:
|
||||||
|
LATEST_BRANCH: "${{ github.event.repository.default_branch }}"
|
||||||
|
DOCKER_REPOSITORY: "zabbix"
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
build:
|
||||||
|
- build-base-mysql
|
||||||
|
- build-base-pgsql
|
||||||
|
- build-base-sqlite3
|
||||||
|
os:
|
||||||
|
- alpine
|
||||||
|
- ubuntu
|
||||||
|
- ol
|
||||||
|
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Prepare platform list
|
||||||
|
id: platform
|
||||||
|
run: |
|
||||||
|
DOCKER_PLATFORM="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x"
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "ubuntu" ]; then
|
||||||
|
DOCKER_PLATFORM="linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "ol" ]; then
|
||||||
|
DOCKER_PLATFORM="linux/amd64,linux/arm64"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ::set-output name=list::${DOCKER_PLATFORM}
|
||||||
|
|
||||||
|
- 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 "::debug::Branch - ${GIT_BRANCH}"
|
||||||
|
|
||||||
|
if [ "${GIT_BRANCH}" == "trunk" ]; then
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}")
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}")
|
||||||
|
else
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}-latest")
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}-latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-latest")
|
||||||
|
fi
|
||||||
|
|
||||||
|
TAGS=$(printf -- "%s, " "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
echo "::debug::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=base_tag::${TAGS_ARRAY[1]#*:}
|
||||||
|
|
||||||
|
- name: Prepare environment (release)
|
||||||
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
|
id: prepare_release
|
||||||
|
run: |
|
||||||
|
TAGS_ARRAY=()
|
||||||
|
|
||||||
|
IMAGE_NAME="${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}"
|
||||||
|
RELEASE_VERSION="${{ github.ref }}"
|
||||||
|
RELEASE_VERSION=${RELEASE_VERSION:10}
|
||||||
|
GIT_BRANCH=${RELEASE_VERSION%.*}
|
||||||
|
|
||||||
|
echo "::debug::Release version ${RELEASE_VERSION}. Branch ${GIT_BRANCH}"
|
||||||
|
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${RELEASE_VERSION}")
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${RELEASE_VERSION}-${{ matrix.os }}")
|
||||||
|
|
||||||
|
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
||||||
|
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_versions::$(printf -- ",%s" "${TAGS_ARRAY[@]}")
|
||||||
|
echo ::set-output name=base_tag::${TAGS_ARRAY[1]#*:}
|
||||||
|
|
||||||
|
- name: Prepare tags
|
||||||
|
id: prepare_tags
|
||||||
|
run: |
|
||||||
|
if [ ! -z "${{ steps.prepare_push.outputs.image_tag_versions }}" ]; then
|
||||||
|
TAGS="${{ steps.prepare_push.outputs.image_tag_versions }}"
|
||||||
|
IMAGE_NAME="${{ steps.prepare_push.outputs.image_name }}"
|
||||||
|
BASE_TAG="${{ steps.prepare_push.outputs.base_tag }}"
|
||||||
|
elif [ ! -z "${{ steps.prepare_release.outputs.image_tag_versions }}" ]; then
|
||||||
|
TAGS="${{ steps.prepare_release.outputs.image_tag_versions }}"
|
||||||
|
IMAGE_NAME="${{ steps.prepare_release.outputs.image_name }}"
|
||||||
|
BASE_TAG="${{ steps.prepare_release.outputs.base_tag }}"
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ::set-output name=image_tag_versions::${TAGS}
|
||||||
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
||||||
|
echo ::set-output name=base_tag::${BASE_TAG}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./${{ matrix.build }}/${{ matrix.os }}
|
||||||
|
file: ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
||||||
|
platforms: ${{ steps.platform.outputs.list }}
|
||||||
|
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
||||||
|
tags: ${{ steps.prepare_tags.outputs.image_tag_versions }}
|
||||||
|
build-args: zabbix/zabbix-build-base:${{ steps.prepare_tags.outputs.base_tag }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
Loading…
Reference in New Issue
Block a user