What is Docker

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.

Jenkins

Jenkins…

Photo by Clark Tibbs on Unsplash

Dotnet Core Api with Nginx load balancer in Linux

Go to VS PMC or open CMD in app directory and exec following command

dotnet publish

then..

Copy published files to Linux

I assume Nginx load balancer already configured.

Load balancer config

server {
listen 80;
server_name example.com;

location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

}

restart nginx

systemctl restart nginx

To keep api running

Create service

sudo nano /etc/systemd/system/Example.service

Service configuration

[Unit]
Description= NET Core application on Ubuntu

[Service]
WorkingDirectory=/var/www/html/Example/
ExecStart=/usr/bin/dotnet /var/www/html/Example/Example.Api.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=offershare-web-app
Environment=ASPNETCORE_ENVIRONMENT=Production

[Install]
WantedBy=multi-user.target

Service commands

sudo systemctl enable Example.service
sudo systemctl start Example.service
sudo systemctl status Example.service

Do not forget to follow me :)
Congratz. You did it.

Hasan Hüseyin Özkaya

Code and Electronic person. Fan of digital transformation and IoT

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store