Skip to content

Instantly share code, notes, and snippets.

@farukcan
Last active October 20, 2022 23:31
Show Gist options
  • Save farukcan/9b966d8c01962fd76fcfcddcd05f33ce to your computer and use it in GitHub Desktop.
Save farukcan/9b966d8c01962fd76fcfcddcd05f33ce to your computer and use it in GitHub Desktop.
111MB dotnet core 6.0 alpine docker file
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /source
COPY /. ./
# Install npm - we need node_modules folder
RUN apk add --update nodejs npm
RUN npm install
# Build the app
RUN dotnet restore
RUN dotnet build -c Release
RUN dotnet publish -c Release -o /output
# we need fast and lightweight runtime
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS runtime
# Copy builds - we need fast app!
COPY --from=build /output .
COPY --from=build /source/node_modules ./node_modules
# Run the app - NOTE: Do not forget ENVs
EXPOSE 80/tcp
ENTRYPOINT ["./NameOfYourAppHere"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment