Skip to content

Commit

Permalink
feat: Build images for linux/arm/v7 and linux/arm64 (#9, @schmidp)
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
schmidp authored and PSanetra committed Aug 24, 2023
1 parent a3ffa78 commit d164711
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
9 changes: 5 additions & 4 deletions .github/actions/determine-target-image-tags/action
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
test -n "${GIT_REF}" || ( echo "GIT_REF is not specified" && false )
test -n "${NGINX_TAG}" || ( echo "NGINX_TAG is not specified" && false )
test -n "${MATRIX_NGINX}" || ( echo "MATRIX_NGINX is not specified" && false )
test -n "${DOCKER_REPOSITORY}" || ( echo "DOCKER_REPOSITORY is not specified" && false )

VERSION="$(echo ${GIT_REF} | grep -oE '[0-9]+\.[0-9]+\.[0-9]+.*' | tr -d '\n')"
echo "VERSION=${VERSION}"
Expand Down Expand Up @@ -36,15 +37,15 @@ echo "LATEST_IMAGE_TAG=${LATEST_IMAGE_TAG}"

# Push major version tag only if this is the latest version of that major version
if [ "${VERSION}" = "${LATEST_VERSION_BY_MAJOR}" ]; then
TAGS="${MAJOR_IMAGE_TAG}"
TAGS="${DOCKER_REPOSITORY}:${MAJOR_IMAGE_TAG}"

# Push latest tags only if this is the latest version of the latest major version
if [ "${VERSION}" = "${GLOBAL_LATEST_VERSION}" ]; then
TAGS="${TAGS},${LATEST_IMAGE_TAG}"
TAGS="${TAGS},${DOCKER_REPOSITORY}:${LATEST_IMAGE_TAG}"

# The "latest" tag should be based on nginx:stable-alpine
if [ "${MATRIX_NGINX}" = "stable" ]; then
TAGS="${TAGS},latest"
TAGS="${TAGS},${DOCKER_REPOSITORY}:latest"
fi
fi
fi
Expand All @@ -55,7 +56,7 @@ if [ "${MATRIX_NGINX}" = "{0}" ]; then
TAGS="${TAGS},"
fi

TAGS="${TAGS}${VERSION_IMAGE_TAG}"
TAGS="${TAGS}${DOCKER_REPOSITORY}:${VERSION_IMAGE_TAG}"
fi

echo "::set-output name=tags::${TAGS}"
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/determine-target-image-tags/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
matrix-nginx:
required: true
description: 'Value of matrix.nginx'
docker-repository:
required: true
description: 'The docker-repository to prefix the tags with'
outputs:
tags:
description: 'A comma separated list of tags to push'
Expand All @@ -20,3 +23,4 @@ runs:
GIT_REF: "${{ inputs.git-ref }}"
NGINX_TAG: "${{ inputs.nginx-tag }}"
MATRIX_NGINX: "${{ inputs.matrix-nginx }}"
DOCKER_REPOSITORY: "${{ inputs.docker-repository }}"
21 changes: 16 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,23 @@ jobs:
git-ref: "${{ github.ref }}"
nginx-tag: "${{ steps.target_nginx_tag.outputs.tag }}"
matrix-nginx: "${{ matrix.nginx }}"
- uses: docker/build-push-action@v1
if: ${{ steps.target_tags.outputs.tags != '' }}
docker-repository: "${{ secrets.DOCKER_REPOSITORY }}"
- uses: docker/setup-qemu-action@v2
name: Set up QEMU
- uses: docker/setup-buildx-action@v2
name: Set up Docker Buildx
- uses: docker/login-action@v2
name: Login to Docker Hub
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ secrets.DOCKER_REPOSITORY }}
- uses: docker/build-push-action@v4
name: Build and push
if: ${{ steps.target_tags.outputs.tags != '' }}
with:
context: .
platforms: linux/arm/v7,linux/amd64,linux/arm64
push: true
pull: true
tags: ${{ steps.target_tags.outputs.tags }}
always_pull: true
build_args: NGINX_TAG=${{ steps.target_nginx_tag.outputs.tag }}
build-args: NGINX_TAG=${{ steps.target_nginx_tag.outputs.tag }}
24 changes: 17 additions & 7 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
IMAGE_NAME="${{ secrets.DOCKER_REPOSITORY }}:${IMAGE_TAG}"
echo "::set-output name=image_name::${IMAGE_NAME}"
echo "IMAGE_NAME=${IMAGE_NAME}"
TAGS="${IMAGE_TAG}"
TAGS="${{ secrets.DOCKER_REPOSITORY }}:${IMAGE_TAG}"
if [ "latest" = "${{ matrix.spa_server_major_version }}" ] && [ "stable" = "${{ matrix.nginx }}" ]; then
TAGS="${TAGS},latest"
TAGS="${TAGS},${{ secrets.DOCKER_REPOSITORY }}:latest"
fi
echo "::set-output name=tags::${TAGS}"
echo "TAGS=${TAGS}"
Expand Down Expand Up @@ -70,12 +70,22 @@ jobs:
if: steps.check_if_update_is_necessary.outputs.needs_update == 'true'
- run: "make test NGINX_TAG=\"${{ steps.target_nginx_tag.outputs.tag }}\""
if: steps.check_if_update_is_necessary.outputs.needs_update == 'true'
- uses: docker/build-push-action@v1
if: ${{ steps.check_if_update_is_necessary.outputs.needs_update == 'true' && steps.target_image_name.outputs.tags != '' }}
- uses: docker/setup-qemu-action@v2
name: Set up QEMU
- uses: docker/setup-buildx-action@v2
name: Set up Docker Buildx
- uses: docker/login-action@v2
name: Login to Docker Hub
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ secrets.DOCKER_REPOSITORY }}
- uses: docker/build-push-action@v4
name: Build and push
if: ${{ steps.check_if_update_is_necessary.outputs.needs_update == 'true' && steps.target_image_name.outputs.tags != '' }}
with:
context: .
platforms: linux/arm/v7,linux/amd64,linux/arm64
push: true
pull: true
tags: ${{ steps.target_image_name.outputs.tags }}
always_pull: true
build_args: NGINX_TAG=${{ steps.target_nginx_tag.outputs.tag }}
build-args: NGINX_TAG=${{ steps.target_nginx_tag.outputs.tag }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG NGINX_TAG
FROM hairyhenderson/gomplate:v3-slim as gomplate
FROM hairyhenderson/gomplate:v3 as gomplate
FROM nginxinc/nginx-unprivileged:${NGINX_TAG} as single-page-app-server
COPY --from=gomplate /gomplate /usr/local/bin/gomplate

Expand Down

0 comments on commit d164711

Please sign in to comment.