From 207bd5dac709a7313689e83d260500a9bf244577 Mon Sep 17 00:00:00 2001 From: Danil Titarenko <77471369+danilapog@users.noreply.github.com> Date: Mon, 29 Aug 2022 11:40:25 +0300 Subject: [PATCH 1/9] Add build Documentserver without example (#473) * Add dockerfile for non-example build * Create new symlink for supervisor config * Add ARG for dynamic images specification * Update action version * Add build nonexample after stable build success * Add targets for nonexample build * Cosmetic changes * Update FROM instruction * Add default tag * Remove needless welcome nginx location * Change nonexample image tags * Set correct nonexample image tag * Change tag for nonexample image * Change dockerfile name * Rename dockerfile for release images * Move stable build to dockerfile * Refactoring bake file --- .github/workflows/4testing-build.yml | 4 +-- .github/workflows/stable-build.yml | 53 +++++++++++++++++++++++++--- Dockerfile.production | 24 +++++++++++++ docker-bake.hcl | 20 +++++++++-- 4 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 Dockerfile.production diff --git a/.github/workflows/4testing-build.yml b/.github/workflows/4testing-build.yml index 1a985db..b5a9956 100644 --- a/.github/workflows/4testing-build.yml +++ b/.github/workflows/4testing-build.yml @@ -13,7 +13,7 @@ env: jobs: build: - name: Build + name: "Build image: DocumentServer${{ matrix.edition }}" runs-on: ubuntu-latest continue-on-error: ${{ matrix.condition }} strategy: @@ -33,7 +33,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to Docker Hub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} diff --git a/.github/workflows/stable-build.yml b/.github/workflows/stable-build.yml index 7fd434a..9d7f6df 100644 --- a/.github/workflows/stable-build.yml +++ b/.github/workflows/stable-build.yml @@ -12,7 +12,7 @@ env: jobs: build: - name: Build + name: "Release image: DocumentServer${{ matrix.edition }}" runs-on: ubuntu-latest continue-on-error: ${{ matrix.condition }} strategy: @@ -31,7 +31,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to Docker Hub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} @@ -49,9 +49,9 @@ jobs: 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" - echo "FROM ${{ env.COMPANY_NAME }}/4testing-${{ env.PRODUCT_NAME }}${{ matrix.edition }}:$TAG as ${{ env.PRODUCT_NAME }}-stable" >> Dockerfile.stable - PRODUCT_EDITION=${{ matrix.edition }} PRODUCT_NAME=${{ env.PRODUCT_NAME }} \ - COMPANY_NAME=${{ env.COMPANY_NAME}} DOCKERFILE=Dockerfile.stable \ + PRODUCT_EDITION=${{ matrix.edition }} \ + PRODUCT_NAME=${{ env.PRODUCT_NAME }} \ + COMPANY_NAME=${{ env.COMPANY_NAME}} \ TAG=$TAG \ SHORTER_TAG=$SHORTER_TAG \ SHORTEST_TAG=$SHORTEST_TAG \ @@ -65,3 +65,46 @@ jobs: exit 1 fi shell: bash + + build-nonExample: + name: "Release image: DocumentServer${{ matrix.edition }}-nonExample" + runs-on: ubuntu-latest + needs: [build] + continue-on-error: ${{ matrix.condition }} + strategy: + matrix: + images: ["documentserver-nonexample"] + edition: ["", "-ee", "-de"] + condition: [true] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + 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 + shell: bash diff --git a/Dockerfile.production b/Dockerfile.production new file mode 100644 index 0000000..3c7b3bd --- /dev/null +++ b/Dockerfile.production @@ -0,0 +1,24 @@ +### Arguments avavlivable only for FROM instruction ### +ARG TAG=latest +ARG COMPANY_NAME=onlyoffice +ARG PRODUCT_EDITION= + +### Build main-release ### + +FROM ${COMPANY_NAME}/4testing-documentserver${PRODUCT_EDITION}:${TAG} as documentserver-stable + +### Build nonexample ### + +FROM ${COMPANY_NAME}/documentserver${PRODUCT_EDITION}:${TAG} as documentserver-nonexample + +ARG COMPANY_NAME=onlyoffice +ARG PRODUCT_NAME=documentserver +ARG DS_SUPERVISOR_CONF=/etc/supervisor/conf.d/ds.conf + +### Remove all documentserver-example data ### + +RUN rm -rf /var/www/$COMPANY_NAME/$PRODUCT_NAME-example \ + && rm -rf /etc/$COMPANY_NAME/$PRODUCT_NAME-example \ + && rm -f $DS_SUPERVISOR_CONF \ + && rm -f /etc/nginx/includes/ds-example.conf \ + && ln -s /etc/$COMPANY_NAME/$PRODUCT_NAME/supervisor/ds.conf $DS_SUPERVISOR_CONF diff --git a/docker-bake.hcl b/docker-bake.hcl index 0302790..e7827f8 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -61,15 +61,29 @@ target "documentserver" { target "documentserver-stable" { target = "documentserver-stable" - dockerfile= "${DOCKERFILE}" + dockerfile= "Dockerfile.production" 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"] platforms = ["linux/amd64", "linux/arm64"] args = { - "PRODUCT_EDITION": "${PRODUCT_EDITION}" - "PRODUCT_NAME": "${PRODUCT_NAME}" + "TAG": "${TAG}" "COMPANY_NAME": "${COMPANY_NAME}" + "PRODUCT_NAME": "${PRODUCT_NAME}" + "PRODUCT_EDITION": "${PRODUCT_EDITION}" } } + +target "documentserver-nonexample" { + target = "documentserver-nonexample" + dockerfile = "Dockerfile.production" + tags = [ "docker.io/${COMPANY_NAME}/${PRODUCT_NAME}${PREFIX_NAME}${PRODUCT_EDITION}:${TAG}-nonexample" ] + platforms = ["linux/amd64", "linux/arm64"] + args = { + "TAG": "${TAG}" + "COMPANY_NAME": "${COMPANY_NAME}" + "PRODUCT_NAME": "${PRODUCT_NAME}" + "PRODUCT_EDITION": "${PRODUCT_EDITION}" + } +} From 3626f8cc6c697bc3a84a2c9b4b895d67f0c37a85 Mon Sep 17 00:00:00 2001 From: Danil Titarenko <77471369+danilapog@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:33:23 +0300 Subject: [PATCH 2/9] Build: Set job fail status if some build failed (#488) --- .github/workflows/4testing-build.yml | 3 +-- .github/workflows/stable-build.yml | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/4testing-build.yml b/.github/workflows/4testing-build.yml index b5a9956..cd420b9 100644 --- a/.github/workflows/4testing-build.yml +++ b/.github/workflows/4testing-build.yml @@ -15,12 +15,11 @@ jobs: build: name: "Build image: DocumentServer${{ matrix.edition }}" runs-on: ubuntu-latest - continue-on-error: ${{ matrix.condition }} strategy: + fail-fast: false matrix: images: ["documentserver"] edition: ["", "-ee", "-de"] - condition: [true] steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/stable-build.yml b/.github/workflows/stable-build.yml index 9d7f6df..34d27ad 100644 --- a/.github/workflows/stable-build.yml +++ b/.github/workflows/stable-build.yml @@ -14,12 +14,11 @@ jobs: build: name: "Release image: DocumentServer${{ matrix.edition }}" runs-on: ubuntu-latest - continue-on-error: ${{ matrix.condition }} strategy: + fail-fast: false matrix: images: ["documentserver-stable"] edition: ["", "-ee", "-de"] - condition: [true] steps: - name: Checkout code uses: actions/checkout@v3 @@ -70,12 +69,12 @@ jobs: name: "Release image: DocumentServer${{ matrix.edition }}-nonExample" runs-on: ubuntu-latest needs: [build] - continue-on-error: ${{ matrix.condition }} + if: always() strategy: + fail-fast: false matrix: images: ["documentserver-nonexample"] edition: ["", "-ee", "-de"] - condition: [true] steps: - name: Checkout code uses: actions/checkout@v3 From e44acbebf7a1be2cccda7a912d1f761310d865bc Mon Sep 17 00:00:00 2001 From: Roman Demidov Date: Wed, 31 Aug 2022 12:13:30 +0300 Subject: [PATCH 3/9] Fix KylinOS start error (#471) * Fix KylinOS start error * Small changes * Small changes --- run-document-server.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/run-document-server.sh b/run-document-server.sh index 83aeb00..f0fbd87 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -1,5 +1,7 @@ #!/bin/bash +umask 0022 + function clean_exit { /usr/bin/documentserver-prepare4shutdown.sh } @@ -593,6 +595,8 @@ else update_welcome_page fi +find /etc/${COMPANY_NAME} -exec chown ds:ds {} \; + #start needed local services for i in ${LOCAL_SERVICES[@]}; do service $i start From 713a06e999569e1e94b6973e3de32dd6a585d1a2 Mon Sep 17 00:00:00 2001 From: Danil Titarenko <77471369+danilapog@users.noreply.github.com> Date: Thu, 8 Sep 2022 15:56:49 +0300 Subject: [PATCH 4/9] Add expected build arch (#489) * Add fail status if build unexpected platforms * Build: set exit code for action * Build: Change expected platforms message --- .github/workflows/4testing-build.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/4testing-build.yml b/.github/workflows/4testing-build.yml index cd420b9..0753466 100644 --- a/.github/workflows/4testing-build.yml +++ b/.github/workflows/4testing-build.yml @@ -47,6 +47,7 @@ jobs: DOCKER_TAG=$( echo ${{ env.RELEASE_VERSION }} | sed 's/^.//' ) PACKAGE_VERSION=$( echo $DOCKER_TAG | sed -E 's/(.*)\./\1-/' ) NODE_PLATFORMS=$( echo ${{ steps.buildx.outputs.platforms }} | sed 's/linux\///g' | sed 's/,/ /g' ) + EXPECTED_PLATFORMS="linux/amd64,linux/arm64" echo "Start check avalivable build platforms >>" ### ==>> In this loop we will check all avalivable documentserver architectures. After that all accessed arch will be added to build-platforms list. ### @@ -76,6 +77,15 @@ jobs: echo "DONE: Check passed >> Build for platforms: ${BUILD_PLATFORMS}" echo "Build is starting ... >>" + ### == >> Set exit code for action + if [ ${BUILD_PLATFORMS} == ${EXPECTED_PLATFORMS} ]; then + EXIT_CODE=0 + echo "OK: Build platforms is expected" + else + EXIT_CODE=1 + echo "WARNING: Build platforms is unexpected action is gonna be marked as Failed" + fi + ### ==>> Build and push images at this step ### PRODUCT_EDITION=${{ matrix.edition }} \ PACKAGE_URL=$PACKAGE_URL_BUILD \ @@ -89,6 +99,6 @@ jobs: docker buildx bake \ -f docker-bake.hcl ${{ matrix.images }} \ --push - echo "DONE: Build success >> exit with 0" - exit 0 + echo "DONE: Build success >> exit with ${EXIT_CODE}" + exit ${EXIT_CODE} shell: bash From 61a5a021cf8ce03bb5b2d83758f8f1750ca4c9eb Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Mon, 12 Sep 2022 16:04:56 +0300 Subject: [PATCH 5/9] 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 From b9bfa7b90c34545b1ca2a7f626be99211213ece5 Mon Sep 17 00:00:00 2001 From: Evgeniy Antonyuk Date: Tue, 13 Sep 2022 11:08:04 +0300 Subject: [PATCH 6/9] fix Bug 58778 - Correct the display of container ID for 22.04 (#494) --- run-document-server.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run-document-server.sh b/run-document-server.sh index f0fbd87..fd183a3 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -84,7 +84,7 @@ else JWT_ENABLED="false" fi -[ -z $JWT_SECRET ] && JWT_MESSAGE="JWT is enabled by default. A random secret is generated automatically. Run the command 'docker exec $(cut -c9-20 < /proc/1/cpuset) sudo documentserver-jwt-status.sh' to get information about JWT." +[ -z $JWT_SECRET ] && JWT_MESSAGE='JWT is enabled by default. A random secret is generated automatically. Run the command "docker exec $(sudo docker ps -q) sudo documentserver-jwt-status.sh" to get information about JWT.' JWT_SECRET=${JWT_SECRET:-$(pwgen -s 20)} JWT_HEADER=${JWT_HEADER:-Authorization} @@ -426,12 +426,15 @@ update_welcome_page() { WELCOME_PAGE="${APP_DIR}-example/welcome/docker.html" if [[ -e $WELCOME_PAGE ]]; then DOCKER_CONTAINER_ID=$(basename $(cat /proc/1/cpuset)) + (( ${#DOCKER_CONTAINER_ID} < 12 )) && DOCKER_CONTAINER_ID=$(hostname) if (( ${#DOCKER_CONTAINER_ID} >= 12 )); then if [[ -x $(command -v docker) ]]; then DOCKER_CONTAINER_NAME=$(docker inspect --format="{{.Name}}" $DOCKER_CONTAINER_ID) sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_NAME#/}"'/' -i $WELCOME_PAGE + JWT_MESSAGE=$(echo $JWT_MESSAGE | sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_NAME#/}"'/') else sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_ID::12}"'/' -i $WELCOME_PAGE + JWT_MESSAGE=$(echo $JWT_MESSAGE | sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_ID::12}"'/') fi fi fi From bac88530c1c1a187e0eadf8b1074dcdda74d9cfc Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Fri, 16 Sep 2022 12:28:44 +0300 Subject: [PATCH 7/9] Refactoring testing build (#496) * Fix dockerfile args * Refactoring testing build action * Secret repo baseurl * Fix package version --- .github/workflows/4testing-build.yml | 162 ++++++++++++++++----------- Dockerfile | 15 +-- docker-bake.hcl | 21 +++- 3 files changed, 122 insertions(+), 76 deletions(-) diff --git a/.github/workflows/4testing-build.yml b/.github/workflows/4testing-build.yml index 3d70142..4343507 100644 --- a/.github/workflows/4testing-build.yml +++ b/.github/workflows/4testing-build.yml @@ -2,23 +2,78 @@ name: 4testing multiarch-build on: - push: - tags: - - "v*" + workflow_dispatch: + inputs: + build: + description: 'Build number (ex. 45)' + type: string + required: true + amd64: + type: boolean + description: 'Build AMD64' + default: true + arm64: + type: boolean + description: 'Build ARM64' + default: true + community: + type: boolean + description: 'Build Community Edition' + default: true + enterprise: + type: boolean + description: 'Build Enterprise Edition' + default: true + developer: + type: boolean + description: 'Build Developer Edition' + default: true env: COMPANY_NAME: "onlyoffice" PRODUCT_NAME: "documentserver" jobs: - build: - name: "Build image: DocumentServer${{ matrix.edition }}" + prepare: runs-on: ubuntu-latest + steps: + - id: matrix + run: | + set -ex + + BRANCH_NAME=${GITHUB_REF#refs/heads/} + if ! [[ $BRANCH_NAME == develop || $BRANCH_NAME =~ hotfix || $BRANCH_NAME =~ release ]]; then + echo "Wrong branch." + exit 1 + fi + + [ ${{ github.event.inputs.amd64 }} = true ] && PLATFORMS+=("amd64") + [ ${{ github.event.inputs.arm64 }} = true ] && PLATFORMS+=("arm64") + if [ -z ${PLATFORMS} ]; then + echo "None of the platforms are selected." + exit 1 + fi + + [ ${{ github.event.inputs.community }} = true ] && EDITIONS+=("community") + [ ${{ github.event.inputs.enterprise }} = true ] && EDITIONS+=("enterprise") + [ ${{ github.event.inputs.developer }} = true ] && EDITIONS+=("developer") + if [ -z ${EDITIONS} ]; then + echo "None of the editions are selected." + exit 1 + fi + echo "::set-output name=editions::$(jq -n -c --arg s "${EDITIONS[*]}" '($s|split(" "))')" + outputs: + editions: ${{ steps.matrix.outputs.editions }} + + build: + name: "Build ${{ matrix.image }}-${{ matrix.edition }}" + runs-on: ubuntu-latest + needs: prepare strategy: fail-fast: false matrix: - images: ["documentserver"] - edition: ["", "-ee", "-de"] + image: ["documentserver"] + edition: ${{ fromJSON(needs.prepare.outputs.editions) }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -36,68 +91,49 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - name: Get Tag Name - run: | - echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Build 4testing run: | + set -eux + ### ==>> At this step build variable declaration ### - DOCKER_TAG=$( echo ${{ env.RELEASE_VERSION }} | sed 's/^.//' ) - PACKAGE_VERSION=$( echo $DOCKER_TAG | sed -E 's/(.*)\./\1-/' ) - NODE_PLATFORMS=$( echo ${{ steps.buildx.outputs.platforms }} | sed 's/linux\///g' | sed 's/,/ /g' ) - EXPECTED_PLATFORMS="linux/amd64,linux/arm64" - echo "Start check avalivable build platforms >>" - ### ==>> In this loop we will check all avalivable documentserver architectures. After that all accessed arch will be added to build-platforms list. ### - for ARCH in ${NODE_PLATFORMS}; do - REPO_URL=${{ secrets.REPO_URL }} - if [[ ${{ env.RELEASE_VERSION }} == v99.* ]]; then - REPO_URL=${{ secrets.UNSTABLE_REPO_URL }} - DEVELOP_BUILD=true - fi - PACKAGE_URL_CHECK=${REPO_URL}${{ matrix.edition }}_"$PACKAGE_VERSION"_${ARCH}.deb - STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "${PACKAGE_URL_CHECK}") - if [[ "$STATUS" = "200" ]]; then - echo "✔ ${ARCH} is avalivable >> set like one of build platforms" - PLATFORMS+=(linux/${ARCH},) - BUILD_PLATFORMS=$( echo ${PLATFORMS[@]} | sed 's/ //g' | sed 's/\(.*\),/\1/' ) - else - echo "Х ${ARCH} in not avalivable" - fi - done - PACKAGE_URL_BUILD=$( echo ${PACKAGE_URL_CHECK} | sed -e "s/${PACKAGE_VERSION}_.*.deb/${PACKAGE_VERSION}_TARGETARCH.deb/g" ) + case ${{ matrix.edition }} in + community) + PRODUCT_EDITION="" + ;; + enterprise) + PRODUCT_EDITION="-ee" + ;; + developer) + PRODUCT_EDITION="-de" + ;; + esac - ### ==>> At this step if there is no access to any platform and platform list is empty, build will exit with 1. ### - if [[ -z ${BUILD_PLATFORMS} ]]; then - echo "Have no access to any platform >> exit with 1" - exit 1 + [ ${{ github.event.inputs.amd64 }} = true ] && PLATFORMS+=("amd64") + [ ${{ github.event.inputs.arm64 }} = true ] && PLATFORMS+=("arm64") + PLATFORM=$(echo ${PLATFORMS[*]/#/linux/} | tr ' ' ',') + + BRANCH_NAME=${GITHUB_REF#refs/heads/} + if [ $BRANCH_NAME = develop ]; then + RELEASE_BRANCH=unstable + PRODUCT_VERSION=99.99.99 + elif [[ $BRANCH_NAME =~ hotfix || $BRANCH_NAME =~ release ]]; then + RELEASE_BRANCH=testing + PRODUCT_VERSION=${BRANCH_NAME#*/v} fi - echo "DONE: Check passed >> Build for platforms: ${BUILD_PLATFORMS}" - echo "Build is starting ... >>" + BUILD_NUMBER=${{ github.event.inputs.build }} - ### == >> Set exit code for action - if [ ${BUILD_PLATFORMS} == ${EXPECTED_PLATFORMS} ]; then - EXIT_CODE=0 - echo "OK: Build platforms is expected" - else - EXIT_CODE=1 - echo "WARNING: Build platforms is unexpected action is gonna be marked as Failed" - fi + export PRODUCT_EDITION + export PACKAGE_VERSION=${PRODUCT_VERSION}-${BUILD_NUMBER} + export PACKAGE_BASEURL=${{ secrets.REPO_BASEURL }}/${RELEASE_BRANCH}/ubuntu + export RELEASE_BRANCH + export PLATFORM + export DOCKERFILE=Dockerfile + export PREFIX_NAME=4testing- + export TAG=${PRODUCT_VERSION}.${BUILD_NUMBER} - ### ==>> Build and push images at this step ### - PRODUCT_EDITION=${{ matrix.edition }} \ - PACKAGE_URL=$PACKAGE_URL_BUILD \ - PRODUCT_NAME=${{ env.PRODUCT_NAME }} \ - DOCKERFILE=Dockerfile \ - PREFIX_NAME=4testing- \ - TAG=$DOCKER_TAG \ - PLATFORM=$BUILD_PLATFORMS \ - COMPANY_NAME=${{ env.COMPANY_NAME }} \ - DEVELOP_BUILD=$DEVELOP_BUILD \ - docker buildx bake \ - -f docker-bake.hcl ${{ matrix.images }} \ - --push - echo "DONE: Build success >> exit with ${EXIT_CODE}" - exit ${EXIT_CODE} + ### ==>> Build and push images at this step ### + + docker buildx bake -f docker-bake.hcl ${{ matrix.image }} --push + echo "DONE: Build success" shell: bash diff --git a/Dockerfile b/Dockerfile index dc73ab6..66a9137 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,25 +71,26 @@ COPY run-document-server.sh /app/ds/run-document-server.sh EXPOSE 80 443 -ARG TARGETARCH -ARG PRODUCT_EDITION= ARG COMPANY_NAME=onlyoffice ARG PRODUCT_NAME=documentserver -ARG PACKAGE_URL="http://download.onlyoffice.com/install/documentserver/linux/${COMPANY_NAME}-${PRODUCT_NAME}${PRODUCT_EDITION}_$TARGETARCH.deb" +ARG PRODUCT_EDITION= +ARG PACKAGE_VERSION=0.0.0-0 +ARG TARGETARCH +ARG PACKAGE_BASEURL="http://download.onlyoffice.com/install/documentserver/linux" +ARG PACKAGE_FILE="${COMPANY_NAME}-${PRODUCT_NAME}${PRODUCT_EDITION}_${PACKAGE_VERSION}_${TARGETARCH}.deb" ENV COMPANY_NAME=$COMPANY_NAME \ PRODUCT_NAME=$PRODUCT_NAME \ PRODUCT_EDITION=$PRODUCT_EDITION -RUN PACKAGE_URL=$( echo ${PACKAGE_URL} | sed "s/TARGETARCH/"${TARGETARCH}"/g") && \ - wget -q -P /tmp "$PACKAGE_URL" && \ +RUN wget -q -P /tmp "$PACKAGE_BASEURL/$PACKAGE_FILE" && \ apt-get -y update && \ service postgresql start && \ - apt-get -yq install /tmp/$(basename "$PACKAGE_URL") && \ + apt-get -yq install /tmp/$PACKAGE_FILE && \ service postgresql stop && \ service supervisor stop && \ chmod 755 /app/ds/*.sh && \ - rm -f /tmp/$(basename "$PACKAGE_URL") && \ + rm -f /tmp/$PACKAGE_FILE && \ rm -rf /var/log/$COMPANY_NAME && \ rm -rf /var/lib/apt/lists/* diff --git a/docker-bake.hcl b/docker-bake.hcl index a7ee963..b797d46 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -26,6 +26,10 @@ variable "PRODUCT_NAME" { default = "" } +variable "PACKAGE_VERSION" { + default = "" +} + variable "DOCKERFILE" { default = "" } @@ -34,11 +38,15 @@ variable "PLATFORM" { default = "" } -variable "PACKAGE_URL" { +variable "PACKAGE_BASEURL" { default = "" } -variable "DEVELOP_BUILD" { +variable "PACKAGE_FILE" { + default = "" +} + +variable "RELEASE_BRANCH" { default = "" } @@ -47,14 +55,15 @@ target "documentserver" { 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": "", + equal("testing",RELEASE_BRANCH) ? "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:latest": "", ] platforms = ["${PLATFORM}"] args = { - "PRODUCT_EDITION": "${PRODUCT_EDITION}" - "PRODUCT_NAME": "${PRODUCT_NAME}" "COMPANY_NAME": "${COMPANY_NAME}" - "PACKAGE_URL": "${PACKAGE_URL}" + "PRODUCT_NAME": "${PRODUCT_NAME}" + "PRODUCT_EDITION": "${PRODUCT_EDITION}" + "PACKAGE_VERSION": "${PACKAGE_VERSION}" + "PACKAGE_BASEURL": "${PACKAGE_BASEURL}" "PLATFORM": "${PLATFORM}" } } From 67fbd9d9c80fb2108c143d509b0e61c4ef612e15 Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Sun, 18 Sep 2022 16:20:15 +0300 Subject: [PATCH 8/9] Fix makefile (#498) --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f840a15..ab7f2c2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ COMPANY_NAME ?= ONLYOFFICE GIT_BRANCH ?= develop PRODUCT_NAME ?= DocumentServer +PRODUCT_EDITION ?= PRODUCT_VERSION ?= 0.0.0 BUILD_NUMBER ?= 0 ONLYOFFICE_VALUE ?= onlyoffice @@ -11,9 +12,9 @@ COMPANY_NAME_LOW = $(shell echo $(COMPANY_NAME) | tr A-Z a-z) PRODUCT_NAME_LOW = $(shell echo $(PRODUCT_NAME) | tr A-Z a-z) COMPANY_NAME_LOW_ESCAPED = $(subst -,,$(COMPANY_NAME_LOW)) -PACKAGE_NAME := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW) +PACKAGE_NAME := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)$(PRODUCT_EDITION) PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER) -PACKAGE_URL := http://$(S3_BUCKET).s3.amazonaws.com/$(COMPANY_NAME_LOW)/$(RELEASE_BRANCH)/ubuntu/$(PACKAGE_NAME)_$(PACKAGE_VERSION)_amd64.deb +PACKAGE_BASEURL := https://s3.eu-west-1.amazonaws.com/$(S3_BUCKET)/$(COMPANY_NAME_LOW)/$(RELEASE_BRANCH)/ubuntu ifeq ($(RELEASE_BRANCH),$(filter $(RELEASE_BRANCH),unstable testing)) DOCKER_TAG := $(subst -,.,$(PACKAGE_VERSION)) @@ -22,7 +23,7 @@ else endif DOCKER_IMAGE := $(subst -,,$(COMPANY_NAME_LOW))/4testing-$(PRODUCT_NAME_LOW) -DOCKER_DUMMY := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)__$(DOCKER_TAG).dummy +DOCKER_DUMMY := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)$(PRODUCT_EDITION)__$(DOCKER_TAG).dummy DOCKER_ARCH := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)_$(PACKAGE_VERSION).tar.gz DOCKER_ARCH_URI := $(COMPANY_NAME_LOW)/$(RELEASE_BRANCH)/docker/$(notdir $(DOCKER_ARCH)) @@ -31,9 +32,12 @@ DOCKER_ARCH_URI := $(COMPANY_NAME_LOW)/$(RELEASE_BRANCH)/docker/$(notdir $(DOCKE $(DOCKER_DUMMY): docker pull ubuntu:20.04 docker build \ - --build-arg PACKAGE_URL=$(PACKAGE_URL) \ --build-arg COMPANY_NAME=$(COMPANY_NAME_LOW) \ --build-arg PRODUCT_NAME=$(PRODUCT_NAME_LOW) \ + --build-arg PRODUCT_EDITION=$(PRODUCT_EDITION) \ + --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) \ + --build-arg PACKAGE_BASEURL=$(PACKAGE_BASEURL) \ + --build-arg TARGETARCH=amd64 \ --build-arg ONLYOFFICE_VALUE=$(ONLYOFFICE_VALUE) \ -t $(DOCKER_IMAGE):$(DOCKER_TAG) . && \ mkdir -p $$(dirname $@) && \ From 29bb07d2cb53b832c2e4bc200bd292168ab9487a Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Tue, 20 Sep 2022 14:20:10 +0300 Subject: [PATCH 9/9] Fix makefile docker image (#499) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ab7f2c2..e255521 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ else DOCKER_TAG := $(subst -,.,$(PACKAGE_VERSION))-$(subst /,-,$(GIT_BRANCH)) endif -DOCKER_IMAGE := $(subst -,,$(COMPANY_NAME_LOW))/4testing-$(PRODUCT_NAME_LOW) +DOCKER_IMAGE := $(subst -,,$(COMPANY_NAME_LOW))/4testing-$(PRODUCT_NAME_LOW)$(PRODUCT_EDITION) DOCKER_DUMMY := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)$(PRODUCT_EDITION)__$(DOCKER_TAG).dummy DOCKER_ARCH := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)_$(PACKAGE_VERSION).tar.gz DOCKER_ARCH_URI := $(COMPANY_NAME_LOW)/$(RELEASE_BRANCH)/docker/$(notdir $(DOCKER_ARCH))