From 61a5a021cf8ce03bb5b2d83758f8f1750ca4c9eb Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Mon, 12 Sep 2022 16:04:56 +0300 Subject: [PATCH] Refactoring stable build (#490) * Refactoring stable build * Build: setting up push 4enterprise images * Cosmetic change * Remove needless tag * Rename dockerfile * Small fix * Rename dockerfile for nonexample Co-authored-by: danilapog --- .github/workflows/4testing-build.yml | 1 - .github/workflows/stable-build.yml | 71 ++++++++----------- docker-bake.hcl | 9 +-- ...erfile.production => production.dockerfile | 0 4 files changed, 33 insertions(+), 48 deletions(-) rename Dockerfile.production => production.dockerfile (100%) diff --git a/.github/workflows/4testing-build.yml b/.github/workflows/4testing-build.yml index 0753466..3d70142 100644 --- a/.github/workflows/4testing-build.yml +++ b/.github/workflows/4testing-build.yml @@ -5,7 +5,6 @@ on: push: tags: - "v*" - - "!v*-stable" env: COMPANY_NAME: "onlyoffice" diff --git a/.github/workflows/stable-build.yml b/.github/workflows/stable-build.yml index 34d27ad..0b6918e 100644 --- a/.github/workflows/stable-build.yml +++ b/.github/workflows/stable-build.yml @@ -2,9 +2,12 @@ name: Multi-arch build stable on: - push: - tags: - - "v*-stable" + workflow_dispatch: + inputs: + tag: + description: 'Tag for release (ex. 1.2.3.45)' + type: string + required: true env: COMPANY_NAME: "onlyoffice" @@ -35,37 +38,28 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - name: Get Tag Name - id: tag_name - run: | - echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} - - name: Build documentserver-release run: | - TAG=$(echo ${{ steps.tag_name.outputs.SOURCE_TAG }} | sed 's/^.//; s/-stable//') - SHORTER_TAG=$(echo ${TAG} | grep -o -P '^[\d]+\.[\d]+\.[\d]+') - SHORTEST_TAG=$(echo ${TAG} | grep -o -P '^[\d]+\.[\d]+') - IMAGE_STATUS=$(docker manifest inspect ${{ env.COMPANY_NAME }}/4testing-${{ env.PRODUCT_NAME }}${{ matrix.edition }}:$TAG > /dev/null ; echo $?) - if [[ "$IMAGE_STATUS" = "0" ]]; then - echo "Image present on docker.hub >> start build stable version" - PRODUCT_EDITION=${{ matrix.edition }} \ - PRODUCT_NAME=${{ env.PRODUCT_NAME }} \ - COMPANY_NAME=${{ env.COMPANY_NAME}} \ - TAG=$TAG \ - SHORTER_TAG=$SHORTER_TAG \ - SHORTEST_TAG=$SHORTEST_TAG \ - docker buildx bake \ - -f docker-bake.hcl ${{ matrix.images }} \ - --push - echo "DONE: Build success >> exit with 0" - exit 0 - else - echo "FAILED: Image with tag $TAG do not presented on docker.hub >> build will not started >> exit with 1" - exit 1 - fi + set -eux + VERSION=${{ github.event.inputs.tag }} + PRODUCT_EDITION=${{ matrix.edition }} + TESTING_IMAGE=${COMPANY_NAME}/4testing-${PRODUCT_NAME}${PRODUCT_EDITION} + if docker manifest inspect ${TESTING_IMAGE}:${VERSION} > /dev/null; then + echo "Image present on docker.hub >> start build stable version" + export PRODUCT_EDITION + export TAG=${VERSION} + export SHORTER_TAG=${VERSION%.*} + export SHORTEST_TAG=${VERSION%.*.*} + docker buildx bake -f docker-bake.hcl ${{ matrix.images }} --push + echo "DONE: Build success >> exit with 0" + exit 0 + else + echo "FAILED: Image with tag ${VERSION} do not presented on docker.hub >> build will not started >> exit with 1" + exit 1 + fi shell: bash - build-nonExample: + build-nonexample: name: "Release image: DocumentServer${{ matrix.edition }}-nonExample" runs-on: ubuntu-latest needs: [build] @@ -91,19 +85,10 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - name: Get Tag Name - id: tag_name - run: | - echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} - - name: build image run: | - TAG=$(echo ${{ steps.tag_name.outputs.SOURCE_TAG }} | sed 's/^.//; s/-stable//') - PRODUCT_EDITION=${{ matrix.edition }} \ - PRODUCT_NAME=${{ env.PRODUCT_NAME }} \ - COMPANY_NAME=${{ env.COMPANY_NAME }} \ - TAG=$TAG \ - docker buildx bake \ - -f docker-bake.hcl ${{ matrix.images }} \ - --push + set -eux + export PRODUCT_EDITION=${{ matrix.edition }} + export TAG=${{ github.event.inputs.tag }} + docker buildx bake -f docker-bake.hcl ${{ matrix.images }} --push shell: bash diff --git a/docker-bake.hcl b/docker-bake.hcl index e7827f8..a7ee963 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -44,7 +44,7 @@ variable "DEVELOP_BUILD" { target "documentserver" { target = "documentserver" - dockerfile= "${DOCKERFILE}" + dockerfile = "${DOCKERFILE}" tags = [ "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}", notequal("",DEVELOP_BUILD) ? "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:latest": "", @@ -61,11 +61,12 @@ target "documentserver" { target "documentserver-stable" { target = "documentserver-stable" - dockerfile= "Dockerfile.production" + dockerfile = "production.dockerfile" tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}", "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${SHORTER_TAG}", "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${SHORTEST_TAG}", - "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:latest"] + "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:latest", + equal("-ee",PRODUCT_EDITION) ? "docker.io/${COMPANY_NAME}4enterprise/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}": "",] platforms = ["linux/amd64", "linux/arm64"] args = { "TAG": "${TAG}" @@ -77,7 +78,7 @@ target "documentserver-stable" { target "documentserver-nonexample" { target = "documentserver-nonexample" - dockerfile = "Dockerfile.production" + dockerfile = "production.dockerfile" tags = [ "docker.io/${COMPANY_NAME}/${PRODUCT_NAME}${PREFIX_NAME}${PRODUCT_EDITION}:${TAG}-nonexample" ] platforms = ["linux/amd64", "linux/arm64"] args = { diff --git a/Dockerfile.production b/production.dockerfile similarity index 100% rename from Dockerfile.production rename to production.dockerfile