mycroforge/Dockerfile
2024-04-21 23:56:27 +02:00

33 lines
1.3 KiB
Docker

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
COPY . /source
WORKDIR /source/MicroForge.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 MicroForge.CLI/scripts /scripts
USER root
ENTRYPOINT ["dotnet", "/app/MicroForge.CLI.dll"] CMD ["-?"]