Skip to content

Instantly share code, notes, and snippets.

@btbytes
Last active May 27, 2020 13:22
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 btbytes/56fe05f9bbb239425fcff45c07f92c32 to your computer and use it in GitHub Desktop.
Save btbytes/56fe05f9bbb239425fcff45c07f92c32 to your computer and use it in GitHub Desktop.
Dotnet in prod

Via https://news.ycombinator.com/item?id=18675776:

Using .NET Core on production here.

but delivering solutions on time and with minimum maintenance requirements afterward is just easier in python or JAVA

I would agree if you would replace Python/Java with Node, but with these languages I don't see it.

on time and with minimum maintenance requirements afterward

This is my Dockerfile, it is serving me without changes (technically replacing 2.1 with 2.2 is a change) for more than 6 months.

    # Build assets
    FROM node:8-alpine AS assets
    WORKDIR /app
    COPY src/Website/Package.json ./Website/package.json
    COPY src/Website/Gulpfile.js ./Website/
    COPY src/Website/Static/. ./Website/Static
    WORKDIR /app/Website
    RUN npm install
    RUN npm run build

    # Build project
    FROM microsoft/dotnet:2.2-sdk-alpine AS build
    WORKDIR /app
    COPY src/Website/*.csproj ./Website/
    WORKDIR /app/Website
    RUN dotnet restore
    WORKDIR /app
    COPY src/Website/. ./Website/
    WORKDIR /app/Website
    RUN dotnet publish -c Release -o dist

    # Run project
    FROM microsoft/dotnet:2.2-aspnetcore-runtime-alpine AS runtime
    WORKDIR /app
    COPY --from=build /app/Website/dist ./
    COPY --from=assets /app/Website/Static/dist ./Static/dist
    RUN rm /app/Data/Log/.gitkeep

    ENTRYPOINT ["dotnet", "Website.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment