From 473b49daa837c0a7ab67027b2bd72c351789c413 Mon Sep 17 00:00:00 2001 From: Craig Gill Date: Tue, 19 Mar 2024 11:28:14 -0700 Subject: [PATCH 1/5] rework gh actions --- ...d-tagged-image.yml => build-dev-image.yml} | 25 +++++----- .github/workflows/build-release-image.yml | 48 +++++++++++++++++++ README.md | 11 ++--- app/Dockerfile | 4 +- 4 files changed, 68 insertions(+), 20 deletions(-) rename .github/workflows/{build-tagged-image.yml => build-dev-image.yml} (72%) create mode 100644 .github/workflows/build-release-image.yml diff --git a/.github/workflows/build-tagged-image.yml b/.github/workflows/build-dev-image.yml similarity index 72% rename from .github/workflows/build-tagged-image.yml rename to .github/workflows/build-dev-image.yml index 65d64f7..b9b90e4 100644 --- a/.github/workflows/build-tagged-image.yml +++ b/.github/workflows/build-dev-image.yml @@ -1,27 +1,26 @@ name: Build & Push Docker Image to GitHub on: + pull_request: push: - tags: - - "*.*.*" + branches: + - develop env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + COMMIT_SHA: ${{ github.sha }} jobs: build_image: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v4 - - name: Set up QEMU uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to GHCR if: github.event_name != 'pull_request' uses: docker/login-action@v3 @@ -29,19 +28,21 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata for the Docker image id: meta - uses: docker/metadata-action@v5.0.0 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - + tags: | + latest + ${{ env.COMMIT_SHA }} + ${{ vars.DEVELOP_TAG}} - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: ./app push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.COMMIT_SHA }} labels: ${{ steps.meta.outputs.labels }} build-args: | - RELEASE_TAG=${{ vars.RELEASE_TAG }} + BUILD_TAG=${{ vars.DEVELOP_TAG }} \ No newline at end of file diff --git a/.github/workflows/build-release-image.yml b/.github/workflows/build-release-image.yml new file mode 100644 index 0000000..8126a39 --- /dev/null +++ b/.github/workflows/build-release-image.yml @@ -0,0 +1,48 @@ +name: Build & Push Docker Image to GitHub + +on: + pull_request: + push: + branches: + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + COMMIT_SHA: ${{ github.sha }} + +jobs: + build_image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + latest + ${{ env.COMMIT_SHA }} + ${{ vars.RELEASE_TAG}} + - name: Build, Tag, and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./app + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ env.COMMIT_SHA }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + BUILD_TAG=${{ vars.RELEASE_TAG }} diff --git a/README.md b/README.md index 3cac262..6b5d1dd 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ # Jira Software -This repo is responsible for creating the Jira Software image used for our on-prem Jira servers. +This repo is responsible for creating the Atlassian Jira Docker image for our internal use. -There's not a lot going on in repo itself other than defining a Dockerfile and gitlab-ci.yml file for the CI/CD pipeline. +There's not a lot going on in repo itself other than defining a Dockerfile and a few GitHub Actions. ## Usage To build an image for Jira Software, simply trigger a new run of the default pipeline for this repo via the [GitLab UI](https://it-gitlab.slickdeals.dev/itops/jira-software/-/pipelines) -Set a variable `DEFAULT_RELEASE_TAG` to configure the image version to build. +The image will be built from the Dockerfile in the `app` folder of this repo. There are two images that will be built from these pipelines, an image for use with our Dev environment, and an image for our Production Jira instance. -Ensure you only use semVer format for the `DEFAULT_RELEASE_TAG` variable, or simply leave it unset to run a build against whatever image is currently present at the `latest` tag from the [upstream Docker Hub repo](https://hub.docker.com/r/atlassian/jira-software/tags?page=1&name=latest) +Once built, the Docker Image will be tagged with the Git Commit SHA and the version of Jira Software that was used to build the image. - -The resulting new image will be automatically saved into this Project's [Container Registry](https://it-gitlab.slickdeals.dev/itops/jira-software/container_registry) and should be pullable with Docker CLI from there. +The resulting image will be pushed to the Slickdeals GHCR for use on our systems. diff --git a/app/Dockerfile b/app/Dockerfile index 1cc6687..e05d0f6 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,6 +1,6 @@ -ARG RELEASE_TAG=latest +ARG BUID_TAG=latest -FROM atlassian/jira-software:${RELEASE_TAG}-jdk11 +FROM atlassian/jira-software:${BUILD_TAG}-jdk11 RUN apt-get update && apt-get install wget From ad0565c367c91f6dbdee4eb6c1d0aae964d22a4c Mon Sep 17 00:00:00 2001 From: Craig Gill Date: Tue, 19 Mar 2024 11:31:16 -0700 Subject: [PATCH 2/5] typos huuurd --- app/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Dockerfile b/app/Dockerfile index e05d0f6..41b3fd7 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,4 +1,4 @@ -ARG BUID_TAG=latest +ARG BUILD_TAG=latest FROM atlassian/jira-software:${BUILD_TAG}-jdk11 From 255f812c498801816f755158a918e7a531332de5 Mon Sep 17 00:00:00 2001 From: Craig Gill Date: Tue, 19 Mar 2024 11:38:46 -0700 Subject: [PATCH 3/5] further tweak image creation --- .github/workflows/build-dev-image.yml | 3 +-- .github/workflows/build-release-image.yml | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-dev-image.yml b/.github/workflows/build-dev-image.yml index b9b90e4..5e8817a 100644 --- a/.github/workflows/build-dev-image.yml +++ b/.github/workflows/build-dev-image.yml @@ -1,4 +1,4 @@ -name: Build & Push Docker Image to GitHub +name: Build & Push Jira Development Docker Image to GHCR on: pull_request: @@ -34,7 +34,6 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - latest ${{ env.COMMIT_SHA }} ${{ vars.DEVELOP_TAG}} - name: Build and push Docker image diff --git a/.github/workflows/build-release-image.yml b/.github/workflows/build-release-image.yml index 8126a39..d40a8b5 100644 --- a/.github/workflows/build-release-image.yml +++ b/.github/workflows/build-release-image.yml @@ -1,7 +1,6 @@ -name: Build & Push Docker Image to GitHub +name: Build & Push Jira Release Docker Image to GHCR on: - pull_request: push: branches: - main @@ -34,7 +33,6 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - latest ${{ env.COMMIT_SHA }} ${{ vars.RELEASE_TAG}} - name: Build, Tag, and push Docker image From 3a3e87bdd33abc64688b8cc48840ed4cba369a7a Mon Sep 17 00:00:00 2001 From: Craig Gill Date: Tue, 19 Mar 2024 12:09:34 -0700 Subject: [PATCH 4/5] gh actions doesnt like to push images --- .github/workflows/build-dev-image.yml | 10 +++++++--- .github/workflows/build-release-image.yml | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-dev-image.yml b/.github/workflows/build-dev-image.yml index 5e8817a..f028052 100644 --- a/.github/workflows/build-dev-image.yml +++ b/.github/workflows/build-dev-image.yml @@ -2,6 +2,8 @@ name: Build & Push Jira Development Docker Image to GHCR on: pull_request: + branches: + - develop push: branches: - develop @@ -22,12 +24,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GHCR - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ env.GITHUB_TOKEN }} + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for the Docker image id: meta uses: docker/metadata-action@v5 @@ -36,7 +40,7 @@ jobs: tags: | ${{ env.COMMIT_SHA }} ${{ vars.DEVELOP_TAG}} - - name: Build and push Docker image + - name: Build, Tag, and push Docker image uses: docker/build-push-action@v5 with: context: ./app diff --git a/.github/workflows/build-release-image.yml b/.github/workflows/build-release-image.yml index d40a8b5..c3a9202 100644 --- a/.github/workflows/build-release-image.yml +++ b/.github/workflows/build-release-image.yml @@ -1,6 +1,9 @@ name: Build & Push Jira Release Docker Image to GHCR on: + pull_request: + branches: + - main push: branches: - main @@ -21,12 +24,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GHCR - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ env.GITHUB_TOKEN }} + env: + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for the Docker image id: meta uses: docker/metadata-action@v5 From 623eda9ed7f08476c3c68c0133d4f479f1d935c0 Mon Sep 17 00:00:00 2001 From: Craig Gill Date: Tue, 19 Mar 2024 13:13:51 -0700 Subject: [PATCH 5/5] Buildx doesn't like upper cases in docker image name --- .github/workflows/build-dev-image.yml | 2 +- .github/workflows/build-release-image.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-dev-image.yml b/.github/workflows/build-dev-image.yml index f028052..7b510c7 100644 --- a/.github/workflows/build-dev-image.yml +++ b/.github/workflows/build-dev-image.yml @@ -10,7 +10,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: slickdeals/jira-software COMMIT_SHA: ${{ github.sha }} jobs: diff --git a/.github/workflows/build-release-image.yml b/.github/workflows/build-release-image.yml index c3a9202..f0284a7 100644 --- a/.github/workflows/build-release-image.yml +++ b/.github/workflows/build-release-image.yml @@ -10,7 +10,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: slickdeals/jira-software COMMIT_SHA: ${{ github.sha }} jobs: @@ -23,6 +23,8 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + buildkitd-flags: debug - name: Login to GHCR uses: docker/login-action@v3 with: