From 3651e7190b30756f580fffa71b733448722c77bd Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 11 Nov 2024 10:47:23 +0530 Subject: [PATCH 1/6] ci: build container image --- .github/workflows/builds.yml | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/builds.yml diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 000000000..215a9b2e5 --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,59 @@ +name: Build Container Image +on: + workflow_dispatch: + push: + branches: + - main + - develop + tags: + - "*" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout Entire Repository + 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 GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set Branch + run: | + export APPS_JSON='[{"url": "https://github.com/${{ github.repository }}","branch": "${{ github.ref_name }}"}]' + echo "APPS_JSON_BASE64=$(echo $APPS_JSON | base64 -w 0)" >> $GITHUB_ENV + + - name: Set Image Tag + run: | + echo "IMAGE_TAG=${{ github.ref_name == 'develop' && 'latest' || 'v15' }}" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + repository: frappe/frappe_docker + path: builds + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + context: builds + file: builds/images/layered/Containerfile + tags: > + ghcr.io/${{ github.repository }}:${{ github.ref_name }}, + ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} + build-args: | + "FRAPPE_BRANCH=${{ env.FRAPPE_VERSION }}" + "APPS_JSON_BASE64=${{ env.APPS_JSON_BASE64 }}" + env: + FRAPPE_BRANCH: ${{ github.ref_type == 'tag' || github.ref_name == 'main' && 'version-15' || 'develop' }} From 76b187e5a18c3a0d448b772cda59a97b367af7f8 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 11 Nov 2024 10:50:28 +0530 Subject: [PATCH 2/6] ci: fix frappe branch env variable --- .github/workflows/builds.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 215a9b2e5..d3698a32b 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -33,7 +33,7 @@ jobs: run: | export APPS_JSON='[{"url": "https://github.com/${{ github.repository }}","branch": "${{ github.ref_name }}"}]' echo "APPS_JSON_BASE64=$(echo $APPS_JSON | base64 -w 0)" >> $GITHUB_ENV - + echo "FRAPPE_BRANCH=${{ github.ref_type == 'tag' || github.ref_name == 'main' && 'version-15' || 'develop' }}" >> $GITHUB_ENV - name: Set Image Tag run: | echo "IMAGE_TAG=${{ github.ref_name == 'develop' && 'latest' || 'v15' }}" >> $GITHUB_ENV @@ -55,5 +55,3 @@ jobs: build-args: | "FRAPPE_BRANCH=${{ env.FRAPPE_VERSION }}" "APPS_JSON_BASE64=${{ env.APPS_JSON_BASE64 }}" - env: - FRAPPE_BRANCH: ${{ github.ref_type == 'tag' || github.ref_name == 'main' && 'version-15' || 'develop' }} From 2496f262c6ceee2573ae67e94602521d726644de Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 11 Nov 2024 10:51:59 +0530 Subject: [PATCH 3/6] ci: fix frappe branch env variable name --- .github/workflows/builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index d3698a32b..b9725549d 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -53,5 +53,5 @@ jobs: ghcr.io/${{ github.repository }}:${{ github.ref_name }}, ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} build-args: | - "FRAPPE_BRANCH=${{ env.FRAPPE_VERSION }}" + "FRAPPE_BRANCH=${{ env.FRAPPE_BRANCH }}" "APPS_JSON_BASE64=${{ env.APPS_JSON_BASE64 }}" From c9b38202051bbf0f9866a8341f5e501fdc0de45f Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 11 Nov 2024 12:49:35 +0530 Subject: [PATCH 4/6] ci: build arm64 images --- .github/workflows/builds.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index b9725549d..58f7fb929 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -11,7 +11,13 @@ on: jobs: build: name: Build + runs-on: ubuntu-latest + + strategy: + matrix: + arch: [amd64, arm64] + steps: - name: Checkout Entire Repository uses: actions/checkout@v4 @@ -21,6 +27,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + platforms: linux/${{ matrix.arch }} - name: Login to GitHub Container Registry uses: docker/login-action@v2 From 8fb00360a269895a848feff7090fa4b0b14f82a4 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 11 Nov 2024 12:52:33 +0530 Subject: [PATCH 5/6] ci: fix workflow yaml --- .github/workflows/builds.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 58f7fb929..2f311bbe1 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -27,7 +27,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - platforms: linux/${{ matrix.arch }} + with: + platforms: linux/${{ matrix.arch }} - name: Login to GitHub Container Registry uses: docker/login-action@v2 From b0dbcb90797bcd4301e2f0ef5445a93d5674f5dc Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 11 Nov 2024 12:55:13 +0530 Subject: [PATCH 6/6] chore: fix spaces --- .github/workflows/builds.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 2f311bbe1..b130ab967 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -42,6 +42,7 @@ jobs: export APPS_JSON='[{"url": "https://github.com/${{ github.repository }}","branch": "${{ github.ref_name }}"}]' echo "APPS_JSON_BASE64=$(echo $APPS_JSON | base64 -w 0)" >> $GITHUB_ENV echo "FRAPPE_BRANCH=${{ github.ref_type == 'tag' || github.ref_name == 'main' && 'version-15' || 'develop' }}" >> $GITHUB_ENV + - name: Set Image Tag run: | echo "IMAGE_TAG=${{ github.ref_name == 'develop' && 'latest' || 'v15' }}" >> $GITHUB_ENV