From 9ebde2759d2a4988eee69b5d9b5bc2d144695e74 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Mon, 2 Dec 2024 13:28:48 +0800 Subject: [PATCH] update Dockerfile --- Dockerfile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 056450d..5804c11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 @@ -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"