From 6844a076e3c3b4778139d1a1b04195b561b568ed Mon Sep 17 00:00:00 2001 From: Barak Amar Date: Tue, 4 Oct 2022 12:23:29 +0300 Subject: [PATCH] Build and publish docker images fix and support multiplatform (#4309) * test docker publish * trigger on push * fix push * update build tags * update context * combine both docekr and ecr * fix docker hub login * fix step description * debug and new version * multiplatform builds * bump image version last test * restore the use of publish version and the actions trigger event --- .github/workflows/docker-publish.yaml | 65 ++++++++++++++------------- .github/workflows/esti.yaml | 4 +- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index c4a69cead05..936187801ed 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -15,15 +15,15 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - name: Setup NodeJS + - name: Set up NodeJS uses: actions/setup-node@v3 with: node-version: '16.15.0' - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17.8 id: go @@ -47,43 +47,46 @@ jobs: run: echo "::set-output name=tag::$(echo ${GITHUB_REF##*/} | sed s/^v//g)" id: version - - name: Extract db schema version from ddl migration files - run: echo "::set-output name=dbschema_version::$( (cd pkg/ddl/ && ls -d *.up.sql) | sed -nE '$s/^0*([0-9]+).*/\1/p' )" - id: schema + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + buildkitd-flags: --debug - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 - - name: Build and push to Amazon ECR - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY_LAKEFS: lakefs - ECR_REPOSITORY_LAKECTL: lakectl - DOCKER_BUILDKIT: '1' - run: | - docker build --target lakectl -t $ECR_REGISTRY/$ECR_REPOSITORY_LAKECTL:${{ steps.version.outputs.tag }} --build-arg VERSION=${{ steps.version.outputs.tag }} --label db-schema-version=${{ steps.schema.outputs.dbschema_version}} . - docker push $ECR_REGISTRY/$ECR_REPOSITORY_LAKECTL:${{ steps.version.outputs.tag }} - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY_LAKEFS:${{ steps.version.outputs.tag }} --build-arg VERSION=${{ steps.version.outputs.tag }} --label db-schema-version=${{ steps.schema.outputs.dbschema_version}} . - docker push $ECR_REGISTRY/$ECR_REPOSITORY_LAKEFS:${{ steps.version.outputs.tag }} - - name: Build and push lakectl to Docker hub - uses: docker/build-push-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - build_args: VERSION=${{ steps.version.outputs.tag }} - labels: db-schema-version=${{ steps.schema.outputs.dbschema_version}} + + - name: Build and push lakectl + uses: docker/build-push-action@v3 + with: + context: . target: lakectl - repository: treeverse/lakectl - tags: ${{ steps.version.outputs.tag }},latest + push: true + platforms: linux/amd64,linux/arm64,darwin/amd64,darwin/arm64 + build-args: VERSION=${{ steps.version.outputs.tag }} + tags: | + ${{ steps.login-ecr.outputs.registry }}/lakectl:${{ steps.version.outputs.tag }} + treeverse/lakectl:${{ steps.version.outputs.tag }} + treeverse/lakectl:latest - - name: Build and push lakefs to Docker hub - uses: docker/build-push-action@v1 + - name: Build and push lakefs + uses: docker/build-push-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - build_args: VERSION=${{ steps.version.outputs.tag }} - labels: db-schema-version=${{ steps.schema.outputs.dbschema_version}} + context: . target: lakefs - repository: treeverse/lakefs - tags: ${{ steps.version.outputs.tag }},latest + push: true + platforms: linux/amd64,linux/arm64,darwin/amd64,darwin/arm64 + build-args: VERSION=${{ steps.version.outputs.tag }} + tags: | + ${{ steps.login-ecr.outputs.registry }}/lakefs:${{ steps.version.outputs.tag }} + treeverse/lakefs:${{ steps.version.outputs.tag }} + treeverse/lakefs:latest diff --git a/.github/workflows/esti.yaml b/.github/workflows/esti.yaml index b36bb7e3377..b9ea9e80c5d 100644 --- a/.github/workflows/esti.yaml +++ b/.github/workflows/esti.yaml @@ -90,7 +90,7 @@ jobs: node-version: '16.15.0' - name: Setup Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17.8 id: go @@ -515,7 +515,7 @@ jobs: uses: actions/checkout@v2 - name: Setup Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17.8 id: go