Skip to content

Instantly share code, notes, and snippets.

@ScriptBytes
Created March 14, 2022 01:05
Show Gist options
  • Save ScriptBytes/65cc845993f70c66380aea45b7af2acb to your computer and use it in GitHub Desktop.
Save ScriptBytes/65cc845993f70c66380aea45b7af2acb to your computer and use it in GitHub Desktop.
A simple dockerfile for a .net core 6 API
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env
# Copy csproj and restore as distinct layers
COPY ./TodoAPI/TodoAPI.csproj ./TodoAPI/TodoAPI.csproj
COPY *.sln .
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o build --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env ./build .
ENV ASPNETCORE_URLS=http://*:8080
EXPOSE 8080
ENTRYPOINT [ "dotnet", "TodoAPI.dll" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment