Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonny64bit/f2d2d6ab67f60706f19137750b901129 to your computer and use it in GitHub Desktop.
Save jonny64bit/f2d2d6ab67f60706f19137750b901129 to your computer and use it in GitHub Desktop.
Docker file .net example.
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
RUN apt-get update -yq \
&& apt-get install curl gnupg -yq \
&& curl -sL https://deb.nodesource.com/setup_15.x | bash \
&& apt-get install nodejs -yq
WORKDIR /src
COPY ["Cat.Web/Cat.Web.csproj", "Cat.Web/"]
RUN dotnet restore "Cat.Web/Cat.Web.csproj"
COPY . .
WORKDIR "/src/Cat.Web"
RUN npm install --ignore-scripts
RUN npm rebuild
RUN npm run build-prod
RUN dotnet build "Cat.Web.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Cat.Web.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Cat.Web.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment