Skip to content

Commit

Permalink
Merge pull request #1 from trifork/feature/multiArcBuild
Browse files Browse the repository at this point in the history
Add build steps to build with arm64 as well
  • Loading branch information
bakgaard authored Aug 20, 2024
2 parents 168274d + 402bed5 commit bcdf8b4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 15 deletions.
66 changes: 57 additions & 9 deletions .github/workflows/new-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ on:
# https://crontab.guru/#0_7_*_*_1-5
- cron: "0 7 * * 1-5"

# permissions are needed if pushing to ghcr.io
permissions:
packages: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
trigger-from-upstream:
Expand All @@ -29,8 +34,9 @@ jobs:
fetch-depth: 0
# fetch-tags: true # Does not work for some reason, so we we use fetch-depth: 0

# https://github.com/fut-infrastructure/ig-publisher/settings/variables/actions
- name: Pipeline debug
if: vars.DEBUG == 'true' # https://github.com/fut-infrastructure/ig-publisher/settings/variables/actions
if: vars.DEBUG == 'true'
run: |
echo "Files:"
ls -lav
Expand All @@ -55,13 +61,16 @@ jobs:
- name: Get the latest FUT release
id: fut
env:
name: ${{ env.IMAGE_NAME }}
run: |
# https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---sortltkeygt
# https://remarkablemark.org/blog/2023/04/15/how-to-grep-for-semver/
fut_version=$(git tag --sort=committerdate \
| grep -Eo '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}' \
| tail -1 \
| sed 's/\\n//g') # Remove any newlines.
echo "image_output=${name,,}" >> $GITHUB_OUTPUT
echo "Latest SemVer tag: $fut_version"
echo "fut_version=$fut_version" >> $GITHUB_OUTPUT
echo "Found FUT release: \"$fut_version\""
Expand All @@ -74,15 +83,54 @@ jobs:
git tag ${{ steps.upstream.outputs.upstream_version }}
git push origin ${{ steps.upstream.outputs.upstream_version }}
- name: build
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta # you'll use this in the next step
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: ${{ env.REGISTRY }}/${{ steps.fut.outputs.image_output }}
# Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,latest
type=semver,pattern={{version}},value=${{ steps.fut.outputs.fut_version }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
if: >-
(steps.upstream.outputs.upstream_version != steps.fut.outputs.fut_version) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.force_build == 'true')
uses: aevea/[email protected]
with:
registry: ${{ env.REGISTRY }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ig-publisher
tag_with_latest: true
tag: ${{ steps.fut.outputs.fut_version }}
extra_args: ${{ format('--build-arg IG_PUB_VERSION={0}', steps.fut.outputs.fut_version) }}
context: .
platforms: linux/amd64,linux/arm64/v8
build-args: ${{ steps.fut.outputs.fut_version }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ LABEL maintainer="Henning C. Nielsen"
LABEL org.opencontainers.image.description="FHIR Implementation Guide Publisher"
LABEL org.opencontainers.image.vendor="FUT Infrastructure"

# https://github.com/codacy/codacy-hadolint/blob/master/codacy-hadolint/docs/description/DL4006.md
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ARG user=publisher
# ARG group=publisher
# ARG uid=1000
# ARG gid=1000

ARG IG_PUB_VERSION # Is set by the pipeline

# https://github.com/codacy/codacy-hadolint/blob/master/docs/description/DL4006.md
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# https://github.com/nodesource/distributions?tab=readme-ov-file#debian-versions
# hadolint ignore=DL3008,DL3028,DL3016
RUN sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sources \
RUN sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sources \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
build-essential \
Expand All @@ -31,7 +31,6 @@ RUN sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sou
ttf-mscorefonts-installer \
fontconfig \
&& fc-cache -f -v \
\
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install --yes --no-install-recommends nodejs \
\
Expand All @@ -42,8 +41,8 @@ RUN sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sou
&& npm install -g fsh-sushi \
\
&& mkdir input-cache \
&& curl -fsSL https://github.com/HL7/fhir-ig-publisher/releases/download/${IG_PUB_VERSION}/publisher.jar -o input-cache/publisher.jar \
\
&& curl -fsSL https://github.com/HL7/fhir-ig-publisher/releases/download/${IG_PUB_VERSION}/publisher.jar -o input-cache/publisher.jar \
&& apt-get autoremove --yes curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
Expand Down

0 comments on commit bcdf8b4

Please sign in to comment.