Skip to content

Commit

Permalink
update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
WeihanLi authored Dec 2, 2024
1 parent 4dbb214 commit 9ebde27
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net9.0-cross-arm64-musl AS cross-build-env

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net9.0-cross-arm64 AS cross-build-env

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build-env

COPY --from=cross-build-env /crossrootfs /crossrootfs

Expand All @@ -11,9 +10,9 @@ ARG BUILDARCH
# Configure NativeAOT Build Prerequisites
# https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=linux-alpine%2Cnet8
# for alpine
# RUN apk update && apk add clang build-base zlib-dev
RUN apk update && apk add clang build-base zlib-dev
# for debian/ubuntu
RUN apt-get update && apt-get install -y clang zlib1g-dev binutils-aarch64-linux-gnu
# RUN apt-get update && apt-get install -y clang zlib1g-dev binutils-aarch64-linux-gnu

WORKDIR /app

Expand All @@ -29,12 +28,11 @@ WORKDIR /app/src/HTTPie/
RUN if [ "${TARGETARCH}" = "${BUILDARCH}" ]; then \
dotnet publish -f net9.0 --use-current-runtime -p:AssemblyName=http -p:TargetFrameworks=net9.0 -o /app/artifacts; \
else \
dotnet publish -f net9.0 -r linux-arm64 -p:AssemblyName=http -p:TargetFrameworks=net9.0 -p:SysRoot=/crossrootfs/arm64 -p:ObjCopyName=aarch64-linux-gnu-objcopy -o /app/artifacts; \
apk add binutils-aarch64 --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
dotnet publish -f net9.0 -r linux-arm64-musl -p:AssemblyName=http -p:TargetFrameworks=net9.0 -p:SysRoot=/crossrootfs/arm64-musl -p:ObjCopyName=aarch64-linux-gnu-objcopy -o /app/artifacts; \
fi

RUN apt install -y file && file /app/artifacts/http

FROM scratch
FROM alpine

# https://github.com/opencontainers/image-spec/blob/main/annotations.md
LABEL org.opencontainers.image.authors="WeihanLi"
Expand Down

0 comments on commit 9ebde27

Please sign in to comment.