diff --git a/.github/workflows/docker-drawio-desktop-headless.yaml b/.github/workflows/docker-drawio-desktop-headless.yaml index e0e850a..05fb523 100644 --- a/.github/workflows/docker-drawio-desktop-headless.yaml +++ b/.github/workflows/docker-drawio-desktop-headless.yaml @@ -42,10 +42,31 @@ jobs: !tests/data/*/*.drawio if: ${{ always() }} + build-multiarch: + runs-on: ubuntu-latest + concurrency: + group: build-multiarch-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v3 + - uses: rlespinasse/github-slug-action@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: 'arm64,arm' + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build docker image + run: make build-multiarch + shell: bash + env: + DOCKER_IMAGE: ${{ github.repository }}:${{ env.GITHUB_REF_SLUG }} + release: runs-on: ubuntu-latest needs: - build + - build-multiarch concurrency: group: release-${{ github.ref }}-${{ github.event_name }} steps: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index bb33a55..9b3d9d3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -8,6 +8,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: rlespinasse/github-slug-action@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 with: @@ -15,3 +17,4 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} tags: 'latest,${{ env.GITHUB_REF_SLUG }}' + platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile b/Dockerfile index 9b3cbae..84caea1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ FROM debian:bullseye +ARG TARGETARCH WORKDIR "/opt/drawio-desktop" ENV DRAWIO_VERSION "21.6.5" RUN set -e; \ + echo "selected arch: ${TARGETARCH}"; \ apt-get update && apt-get install -y \ xvfb \ wget \ @@ -11,9 +13,9 @@ RUN set -e; \ libasound2 \ # Fonts fonts-liberation fonts-arphic-ukai fonts-arphic-uming fonts-noto fonts-noto-cjk fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core \ - ; wget -q https://github.com/jgraph/drawio-desktop/releases/download/v${DRAWIO_VERSION}/drawio-amd64-${DRAWIO_VERSION}.deb \ - && apt-get install -y /opt/drawio-desktop/drawio-amd64-${DRAWIO_VERSION}.deb \ - && rm -rf /opt/drawio-desktop/drawio-amd64-${DRAWIO_VERSION}.deb; \ + ; wget -q https://github.com/jgraph/drawio-desktop/releases/download/v${DRAWIO_VERSION}/drawio-${TARGETARCH}-${DRAWIO_VERSION}.deb \ + && apt-get install -y /opt/drawio-desktop/drawio-${TARGETARCH}-${DRAWIO_VERSION}.deb \ + && rm -rf /opt/drawio-desktop/drawio-${TARGETARCH}-${DRAWIO_VERSION}.deb; \ apt-get remove -y wget; \ rm -rf /var/lib/apt/lists/*; diff --git a/Makefile b/Makefile index 031e99c..aceefc2 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,21 @@ -.PHONY: build build-no-cache cleanup run test test-ci-setup test-ci +.PHONY: build build-no-cache build-multiarch cleanup run test test-ci-setup test-ci + +# amd64 by default, arm64 for arm machine like macbook m1 +ifneq ($(filter arm%,$(shell uname -p)),) +ARCHFLAG := "arm64" +else +ARCHFLAG := "amd64" +endif DOCKER_IMAGE?=rlespinasse/drawio-desktop-headless:local build: - @docker build -t ${DOCKER_IMAGE} . + @docker build --build-arg="TARGETARCH=$(ARCHFLAG)" -t ${DOCKER_IMAGE} . build-no-cache: - @docker build --no-cache --progress plain -t ${DOCKER_IMAGE} . + @docker build --build-arg="TARGETARCH=$(ARCHFLAG)" --no-cache --progress plain -t ${DOCKER_IMAGE} . + +build-multiarch: + @docker buildx build --platform linux/amd64,linux/arm64 -t ${DOCKER_IMAGE} . cleanup: @rm -rf tests/output