FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build COPY . /source WORKDIR /source/MycroForge.CLI ARG TARGETARCH # Leverage a cache mount to /root/.nuget/packages so that subsequent builds don't have to re-download packages. # If TARGETARCH is "amd64", replace it with "x64" - "x64" is .NET's canonical name for this and "amd64" doesn't # work in .NET 6.0. RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim AS final RUN apt update -y && \ apt upgrade -y && \ apt install -y git && \ apt install -y bash && \ apt install -y python3 && \ apt install -y python3-pip && \ apt install -y python3-venv # The Docker approach doesn't work for now, because the venv setup depends on absolute paths. # This means that the would need to recreate the full path to the actual working directory in the Docker container, # which should be pretty doable, but it's a concern for later. ENV PYTHONUNBUFFERED=1 WORKDIR /app COPY --from=build /app . WORKDIR /project COPY MycroForge.CLI/scripts /scripts USER root ENTRYPOINT ["dotnet", "/app/MycroForge.CLI.dll"] CMD ["-?"]