Reputation: 1309
I've been trying to compose a docker file to build a .net 8 app with AOT for linux/arm64.
# Use a smaller base image for build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
EXPOSE 8080
EXPOSE 443
EXPOSE 80
WORKDIR /app
# Install clang/zlib1g-dev dependencies for publishing to native
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
clang zlib1g-dev
# Copy only necessary files for restoring dependencies
COPY *.csproj ./
RUN dotnet restore
COPY . .
FROM --platform=linux/arm64 build-env AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./project.csproj" -c $BUILD_CONFIGURATION -r linux-arm64 -o /app/publish /p:UseAppHost=true
# Use a minimal base image for runtime
#FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-bookworm-slim-arm64v8 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-cbl-mariner2.0-distroless-arm64v8 AS runtime
WORKDIR /app
EXPOSE 8080
COPY --from=publish /app/publish .
ENTRYPOINT ["./project.dll"]
Using the above I can build a non AOT arm64 image but soon as I switch to publish AOT true, I end up with
/usr/bin/ld.bfd: unrecognised emulation mode: aarch64linux
I'm not 100% which images to use anymore - (at least for me) the amount of info on github seems overwhelming and somewhat unclear
Upvotes: 2
Views: 1233