From a02c3c7ceb0af02e9d0a934c0c14e27d7b28b114 Mon Sep 17 00:00:00 2001 From: bennsimon Date: Tue, 27 Apr 2021 13:46:50 +0300 Subject: [PATCH 1/3] add docker ci, add timeout for arm64 builds Co-authored-by: Morris Mukiri --- .github/workflows/docker-publish.yml | 103 +++++++++++++++++++++++++++ Dockerfile | 3 +- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 000000000..17f8912d3 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,103 @@ +name: Docker + +on: + push: + # Publish `master` as Docker `master` tag. + # See also https://github.com/crazy-max/ghaction-docker-meta#basic + branches: + - master + - add-docker-build-push-ci + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + pull_request: + # Run Tests when changes are made to the Docker file + paths: + - 'Dockerfile' + + workflow_dispatch: + inputs: + customTag: + description: "Includes the specified tag to docker image tags" + required: false + +jobs: + # Run image build test + test: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Run Build tests + run: docker build . --file Dockerfile + + push: + runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: opensrp/web + tag-custom: ${{ github.event.inputs.customTag }} + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Push to Docker Image Repositories + uses: docker/build-push-action@v2 + id: docker_build + with: + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.docker_meta.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index ead320ccd..2ef5da2c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,8 @@ RUN chown -R node . USER node RUN cp /project/app/.env.sample /project/app/.env \ - && yarn + && yarn --network-timeout 100000 +# network timeout added to fix an issue with build on arm64 arch https://github.com/yarnpkg/yarn/issues/4890 USER root RUN chown -R node . From 03c7ceaaf918038e24768efaf3719f2d49ea49f0 Mon Sep 17 00:00:00 2001 From: bennsimon Date: Wed, 28 Apr 2021 17:28:01 +0300 Subject: [PATCH 2/3] disable multiplatform builds --- .github/workflows/docker-publish.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 17f8912d3..75604af42 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -46,9 +46,8 @@ jobs: with: submodules: recursive - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - +# - name: Set up QEMU +# uses: docker/setup-qemu-action@v1 - name: Cache Docker layers uses: actions/cache@v2 @@ -86,7 +85,7 @@ jobs: id: docker_build with: push: true - platforms: linux/amd64,linux/arm64 +# platforms: linux/amd64,linux/arm64 tags: ${{ steps.docker_meta.outputs.tags }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new From a61814c8f88d599f54cd49cfa074d1524e68f7fc Mon Sep 17 00:00:00 2001 From: bennsimon Date: Wed, 28 Apr 2021 17:47:09 +0300 Subject: [PATCH 3/3] cleanup --- .github/workflows/docker-publish.yml | 1 - Dockerfile | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 75604af42..7e235faee 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -6,7 +6,6 @@ on: # See also https://github.com/crazy-max/ghaction-docker-meta#basic branches: - master - - add-docker-build-push-ci # Publish `v1.2.3` tags as releases. tags: diff --git a/Dockerfile b/Dockerfile index 2ef5da2c4..ead320ccd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,7 @@ RUN chown -R node . USER node RUN cp /project/app/.env.sample /project/app/.env \ - && yarn --network-timeout 100000 -# network timeout added to fix an issue with build on arm64 arch https://github.com/yarnpkg/yarn/issues/4890 + && yarn USER root RUN chown -R node .