From 79713419a2fa60905285e39e61be16f613a43efb Mon Sep 17 00:00:00 2001 From: Josh Bowen Date: Thu, 10 Nov 2022 08:21:12 -0700 Subject: [PATCH] Update Docker image build pipelines (#990) # PULL REQUEST ## Overview Updates the Docker image build Github Action Pipelines. The `amd64-docker-build` job is run on all pushes to all branches. It creates a `linux/amd64` docker image that is tagged with the short commit sha. [Example Job](https://github.com/jbowen93/celestia-app/actions/runs/3432472621/jobs/5721783469) w/ [resulting image](https://github.com/jbowen93/celestia-app/pkgs/container/celestia-app/49690412?tag=sha-9087311) The `main-docker-build` job runs on pushes to `main` as well as when any new tags are pushed. It creates both a `linux/arm64` image and a `linux/amd64` image. When run against `main` the image is tagged with the short commit sha. When run against a tag the image is tagged with the git tag. [Example Job](https://github.com/jbowen93/celestia-app/actions/runs/3432479009/jobs/5721797340) w/ [resulting image](https://github.com/jbowen93/celestia-app/pkgs/container/celestia-app/49692397?tag=sha-ff1c238) [Example Job](https://github.com/jbowen93/celestia-app/actions/runs/3432357771) for a tagged run w/ [resulting image](https://github.com/jbowen93/celestia-app/pkgs/container/celestia-app/49690070?tag=0.0.91-rc1). ## Checklist - [x] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords --- .github/workflows/amd64-docker-build.yml | 43 ++++++++++++ .github/workflows/docker-build.yml | 88 ------------------------ .github/workflows/main-docker-build.yml | 45 ++++++++++++ 3 files changed, 88 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/amd64-docker-build.yml delete mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/main-docker-build.yml diff --git a/.github/workflows/amd64-docker-build.yml b/.github/workflows/amd64-docker-build.yml new file mode 100644 index 0000000000..45c0fbaa31 --- /dev/null +++ b/.github/workflows/amd64-docker-build.yml @@ -0,0 +1,43 @@ +name: "amd64-docker-build" + +on: + push: + branches: + - "**" + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + docker-build: + runs-on: "ubuntu-latest" + permissions: + contents: write + packages: write + steps: + - uses: "actions/checkout@v3" + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha + type=semver,pattern={{version}} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + file: Dockerfile diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml deleted file mode 100644 index 2a1b5393b7..0000000000 --- a/.github/workflows/docker-build.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: "docker-build" - -on: - push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" - - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" - - "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" - - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - docker-build: - runs-on: "ubuntu-latest" - permissions: - contents: write - packages: write - steps: - - name: "Checkout source code" - uses: "actions/checkout@v3" - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - name: "Build" - run: "make build" - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to GHCR - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: tag version - uses: nowsprinting/check-version-format-action@v3 - id: tag_version - with: - prefix: "v" - - - name: Build and push - uses: docker/build-push-action@v3 - with: - push: true - # yamllint disable - tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag_version.outputs.full }} - # yamllint enable - file: Dockerfile - - docker-build-ephemeral: - runs-on: "ubuntu-latest" - permissions: - contents: write - packages: write - steps: - - name: "Checkout source code" - uses: "actions/checkout@v3" - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - name: "Build" - run: "make build" - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to GHCR - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v3 - with: - push: true - tags: ghcr.io/celestiaorg/celestia-app-ephemeral:latest - file: docker/Dockerfile_ephemeral diff --git a/.github/workflows/main-docker-build.yml b/.github/workflows/main-docker-build.yml new file mode 100644 index 0000000000..726087646b --- /dev/null +++ b/.github/workflows/main-docker-build.yml @@ -0,0 +1,45 @@ +name: "main-docker-build" + +on: + push: + branches: + - main + tags: + - "v*" + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + docker-build: + runs-on: "ubuntu-latest" + permissions: + contents: write + packages: write + steps: + - uses: "actions/checkout@v3" + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha + type=semver,pattern={{version}} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + platforms: linux/arm64, linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + file: Dockerfile