Skip to content

Commit

Permalink
Merge pull request #183 from nats-io/neil/buildaction
Browse files Browse the repository at this point in the history
Use `docker/build-push-action` for Linux builds
  • Loading branch information
derekcollison authored Sep 12, 2024
2 parents c6a5511 + e1c5abe commit 95b80b9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 49 deletions.
92 changes: 45 additions & 47 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ on:

env:
IMAGE_NAME: "synadia/nats-server"
LINUX_ARCHS: "linux/arm64,linux/arm/v6,linux/arm/v7,linux/amd64,linux/386,linux/s390x,linux/ppc64le"

jobs:
linux-2_10:
name: Build Linux (2.10.x)
if: ${{ startsWith(github.ref_name, 'v2.10.') }}
runs-on: ubuntu-latest

Expand All @@ -26,15 +28,9 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

# Setting up Docker Buildx with docker-container driver is required
# at the moment to be able to use a subdirectory with Git context.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup builder
run: |
docker buildx create --name builder --bootstrap --use
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
- name: Tag Version
id: ref
Expand All @@ -43,25 +39,29 @@ jobs:
TAG=${{ github.ref_name }}
echo "TAG=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: alpine3.20
run: |
docker buildx build \
--platform linux/arm64,linux/arm/v6,linux/arm/v7,linux/amd64,linux/386,linux/s390x,linux/ppc64le \
--tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20" \
--push \
./2.10.x/alpine3.20
- name: scratch
run: |
docker buildx build \
--file ./2.10.x/scratch/Dockerfile.preview \
--build-arg "BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20" \
--platform linux/arm64,linux/arm/v6,linux/arm/v7,linux/amd64,linux/386,linux/s390x,linux/ppc64le \
--tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-scratch" \
--push \
./2.10.x/scratch
- name: Alpine 3.20
uses: docker/build-push-action@v6
with:
context: ./2.10.x/alpine3.20/
platforms: ${{ env.LINUX_ARCHS }}
push: true
tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20
provenance: mode=max

- name: Scratch
uses: docker/build-push-action@v6
with:
context: ./2.10.x/scratch/
file: ./2.10.x/scratch/Dockerfile.preview
platforms: ${{ env.LINUX_ARCHS }}
push: true
tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-scratch
provenance: mode=max
build-args: |
BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20
windows-2019-2_10:
name: Build Windows (2.10.x)
if: ${{ startsWith(github.ref_name, 'v2.10.') }}
runs-on: windows-2019

Expand Down Expand Up @@ -109,6 +109,7 @@ jobs:
docker push "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-nanoserver-1809"
linux-2_11:
name: Build Linux (2.11.x)
if: ${{ startsWith(github.ref_name, 'v2.11.') }}
runs-on: ubuntu-latest

Expand All @@ -125,42 +126,39 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

# Setting up Docker Buildx with docker-container driver is required
# at the moment to be able to use a subdirectory with Git context.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup builder
run: |
docker buildx create --name builder --bootstrap --use
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
- name: Tag Version
id: ref
shell: bash
run: |
TAG=${{ github.ref_name }}
echo "TAG=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: alpine3.20
run: |
docker buildx build \
--platform linux/arm64,linux/arm/v6,linux/arm/v7,linux/amd64,linux/386,linux/s390x,linux/ppc64le \
--tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20" \
--push \
./2.11.x/alpine3.20
- name: scratch
run: |
docker buildx build \
--file ./2.11.x/scratch/Dockerfile.preview \
--build-arg "BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20" \
--platform linux/arm64,linux/arm/v6,linux/arm/v7,linux/amd64,linux/386,linux/s390x,linux/ppc64le \
--tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-scratch" \
--push \
./2.11.x/scratch
- name: Alpine 3.20
uses: docker/build-push-action@v6
with:
context: ./2.11.x/alpine3.20/
platforms: ${{ env.LINUX_ARCHS }}
push: true
tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20
provenance: mode=max

- name: Scratch
uses: docker/build-push-action@v6
with:
context: ./2.11.x/scratch/
file: ./2.11.x/scratch/Dockerfile.preview
platforms: ${{ env.LINUX_ARCHS }}
push: true
tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-scratch
provenance: mode=max
build-args: |
BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.20
windows-2019-2_11:
name: Build Windows (2.11.x)
if: ${{ startsWith(github.ref_name, 'v2.11.') }}
runs-on: windows-2019

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
linux:
name: Linux (${{ matrix.version }})
name: Test Linux (${{ matrix.version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -22,7 +22,7 @@ jobs:
cd ./${{ matrix.version }}/tests && ./run-images.sh
windows:
name: Windows Server 2019 (${{ matrix.version }})
name: Test Windows Server 2019 (${{ matrix.version }})
runs-on: windows-2019
strategy:
fail-fast: false
Expand Down

0 comments on commit 95b80b9

Please sign in to comment.