Skip to content

Instantly share code, notes, and snippets.

@csharpfritz
Created February 26, 2024 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csharpfritz/396c5581efd551b1217b11e51f6d5a53 to your computer and use it in GitHub Desktop.
Save csharpfritz/396c5581efd551b1217b11e51f6d5a53 to your computer and use it in GitHub Desktop.
Dockerfile for Raspberry Pi 3b sample
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-preview-alpine AS build
ARG TARGETARCH
WORKDIR /source
# copy csproj and restore as distinct layers
COPY Fritz.DemoPi/*.csproj .
RUN dotnet restore -a $TARGETARCH
# copy everything else and build app
COPY Fritz.DemoPi/. .
COPY .git/. .git/.
RUN dotnet publish -a $TARGETARCH --no-restore -o /app
# final stage/image
# .NET 8 tag includes `-preview`
FROM mcr.microsoft.com/dotnet/aspnet:8.0-preview-alpine
# These ENVs are only needed because the sample uses .NET 7
ENV DOTNET_ROLL_FORWARD=Major
ENV DOTNET_ROLL_FORWARD_PRE_RELEASE=1
WORKDIR /app
COPY --from=build /app .
USER $APP_UID
ENTRYPOINT ["./Fritz.DemoPi"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment