Skip to content

Commit

Permalink
fix multi-platform build
Browse files Browse the repository at this point in the history
  • Loading branch information
remcoros committed Jul 28, 2024
1 parent dda805f commit 68631ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine as build
# QEMU crashes when building arm64 container, so we use this pattern to create a multi-platform build:
# https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build

# implicitly set by docker build
ARG TARGETARCH

# install nodejs/npm to build cc-implementation
RUN apk update && apk add --no-cache nodejs npm
Expand All @@ -13,11 +18,11 @@ RUN \
npm install && \
npm run build

# compile PushTX app
# compile PushTX app for target architecture (arm64/amd64)
RUN \
cd /app/PushTX && \
dotnet restore && \
dotnet publish -c Release -o out
dotnet restore -a $TARGETARCH && \
dotnet publish -a $TARGETARCH --no-restore -c Release -o out

# start from aspnet runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
Expand Down
11 changes: 0 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ PKG_VERSION := $(shell yq e ".version" manifest.yaml)
TS_FILES := $(shell find ./scripts -name \*.ts)
SOURCES := $(shell find ./src ! -path "*/obj/*" ! -path "*/bin/*" ! -path "*/node_modules/*")

# sha256 hashes can be found in https://github.com/mikefarah/yq/releases/download/v4.40.7/checksums-bsd
YQ_VERSION := 4.40.7
YQ_SHA_AMD64 := 4f13ee9303a49f7e8f61e7d9c87402e07cc920ae8dfaaa8c10d7ea1b8f9f48ed
YQ_SHA_ARM64 := a84f2c8f105b70cd348c3bf14048aeb1665c2e7314cbe9aaff15479f268b8412

.DELETE_ON_ERROR:

all: verify
Expand Down Expand Up @@ -46,9 +41,6 @@ ifeq ($(ARCH),x86_64)
else
mkdir -p docker-images
docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \
--build-arg PLATFORM=arm64 \
--build-arg YQ_VERSION=$(YQ_VERSION) \
--build-arg YQ_SHA=$(YQ_SHA_ARM64) \
--platform=linux/arm64 -o type=docker,dest=docker-images/aarch64.tar .
endif

Expand All @@ -57,9 +49,6 @@ ifeq ($(ARCH),aarch64)
else
mkdir -p docker-images
docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \
--build-arg PLATFORM=amd64 \
--build-arg YQ_VERSION=$(YQ_VERSION) \
--build-arg YQ_SHA=$(YQ_SHA_AMD64) \
--platform=linux/amd64 -o type=docker,dest=docker-images/x86_64.tar .
endif

Expand Down

0 comments on commit 68631ff

Please sign in to comment.