Alex's Coding Blog
  • Home
  • About
  • Projects
  • Contact me

Blog

Dockerfile for .NET 5 web application

  • January 13, 2021 January 13, 2021
  • by Alexander

Recently, I upgraded a few of my projects to .NET 5.0. Most of project shipped as docker containers, the upgrade requires making some changed to docker files. Converting from .NET Core 2.2/3.1 to .NET 5 is streight forward. Here are some notes from the process:

Dockerfile files are cool when they are working. In order to make them work without additional effort is better to keep similar folder structure between the projects.

I use the following structure for my projects:

/src
/tests
/Dockerfile

.NET application docker file example

# pick image including .net sdk for compilation
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
# change directiry
WORKDIR /app
# copy 
COPY src/ ./
# if special config is used
COPY nuget.config ./
# restore
RUN dotnet restore "./Api.csproj" --configfile "./nuget.config"
# publish
RUN dotnet publish "./Api.csproj" -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0
COPY --from=build-env /app/out .
# expose port
EXPOSE 6032
# set .net app to expose a port
ENV ASPNETCORE_URLS http://*:6032
# run
ENTRYPOINT ["dotnet", "Api.dll"]

If console application is deployed mcr.microsoft.com/dotnet/runtime:5.0 should be used as a build image.

.NET Core DevOps How-to

Debugging microservices is always tricky and time consuming specially without proper code level logging in place.

Meet Konso. It's developed as a solution for this challenge and can help with saving development effort for your team up to 30%. 🎯🎉

The key functions are:

🔥 Centralized logging for your microservices
🔥 Tracing with metrics and value tracking events
🔥 Ad-Hoc events exploration
🔥 Saving your queries
🔥 Create alerts and get notified


You can start collecting you project's logs in 5 minutes. 🕐💪

To Learn more about logging tool, book a free demo.
To get started for free, Create your free account now

Alexander Lvovich

Solution Architect and Software Developer.

Share on:

No comments are allowed for this post

Recent Posts

  • Easily track and troubleshoot errors in your .NET 7 web app using Konso's logging feature
  • How to disable object model validation .NET 7
  • Keep Your Passwords Safe: 5 Tips for Protecting Yourself After the Latest LastPass Data Breach
  • How to ping from .net application container
  • Freelancing myths you should consider before dive in
  • How to set up a honey token for dotnet project with Konso

Categories

  • Azure
  • Architecture
  • .NET Core
  • Certification
  • DevOps
  • How-to
  • Azure Functions
  • Serverless
  • Cosmos DB
  • Security
  • Thoughts
© Copyright 2023, Alexander Lvovich. Theme by Colorlib