Deploying Web Apps

As all Web Apps use the same pre-compiled /web binary, deployment is greatly simplified as it only needs to be concerned with deploying static files and starting web/app.dll with the App's app.settings.

Deploying Web Apps to Ubuntu

A common way for reliably hosting .NET Core Apps on Ubuntu is to use supervisor to monitor the dotnet self-hosting processes behind an nginx reverse proxy which handles external HTTP requests to your website and proxies them to the dotnet process running your Web App on a local port. You'll need access to a Unix environment on your client Desktop, either using Linux, OSX or Installing Windows Subsystem for Linux (WSL).

Setup the deploy User Account

Using a Unix command-line or Windows Subsystem for Linux (WSL) ssh into your remote server:

$ ssh

We'll start by creating a dedicated user account for hosting and running your .NET Core Apps to mitigate potential abuse. SSH into your Ubuntu server and create the deploy user account with a /home/deploy home directory and add them to the sudo group:

sudo useradd -m deploy
sudo usermod -aG sudo deploy

For seamless deployments use visudo to allow deploy to run supervisorctl without prompting for a password:

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
%deploy ALL=NOPASSWD: /usr/bin/supervisorctl, /home/deploy/.dotnet/tools/web

In vi type i to start editing a file and ESC to quit edit mode and :wq to save your changes before exiting.

For simplifying the one-time setup, it's easier to sign-in as super user:

$ sudo su -

Install the dotnet web tool:

$ dotnet tool install -g web

Change into the directory where want to install the app:

$ cd /home/deploy/apps

Install your app from your GitHub project:

$ web install spirals --source mythz

Optional, but you can test that your app runs without issues with:

$ cd spirals && web

Setup nginx

To setup the nginx reverse proxy for this website change into:

$ cd /etc/nginx/sites-available/

Then create an nginx website configuration template with:

web init nginx

Rename it to the domain name you want to host it under:

$ mv

Edit the file and replace it to use your App settings:

$ vi

Specifically you want to change the domain name and port you want to host it on which you can do quickly with the search/replace commands:


Then type :wq to quit vi. To enable the site in nginx we need to create a symbolic link in /sites-enabled:

$ ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Then reload nginx to pick up changes:

$ /etc/init.d/nginx reload

Setup supervisor

Now that we have our website configured with nginx we need to setup supervisor to start and monitor the .NET Core process by changing into:

$ cd /etc/supervisor/conf.d

Then generate a supervisor configuration template with:

$ web init supervisor

Rename it to your Web App's folder name:

$ mv app.spirals.conf

Then use vi to customize the configuration for your App:

$ vi app.spirals.conf

If your apps are located in /home/deploy/apps/ then you can just run the Search/Replace rules:


Which will change it to:

command=/home/deploy/.dotnet/tools/web --release

The --release flag overrides debug in app.settings so it's always run in release mode.

After reviewing the changes, tell supervisor to register and start the supervisor process with:

$ supervisorctl update

Where your website will now be up and running at:

Deploying Updates

After the one-time setup above, updating Web Apps are more easily done with:

$ cd /home/deploy/apps
$ sudo /home/deploy/.dotnet/tools/web install spirals --source mythz
$ sudo supervisorctl restart app-spirals

Which can also be deployed from the Windows Command Prompt using a remote SSH command by combining the above commands in a text file:

ssh -t "cd /home/deploy/apps && sudo /home/deploy/.dotnet/tools/web install spirals --source mythz && sudo supervisorctl restart app-spirals"

Where App updates can then be performed with a single WSL bash command from the Windows Command Prompt:

$ bash

Using Travis CI to deploy using Docker to AWS ECS

A popular combination for deploying .NET Core Apps is to use the online Travis CI Continuous Integration Service to package your App in a Docker Container and deploy it to AWS ECS which takes care of the management and deployment of Docker instances over a configured cluster of EC2 compute instances.

The easiest way to set this up is to clone the rockwind-aws Web App which is preconfigured with a working scripts using Travis CI to package the Web App in a Docker container and deploy it to AWS ECS. In your local copy replace the /app folder with your App files, e.g:


FROM microsoft/dotnet:2.1-sdk AS build-env
COPY app /app
RUN dotnet tool install -g web

# Build runtime image
FROM microsoft/dotnet:2.1-aspnetcore-runtime
COPY --from=build-env /app app
COPY --from=build-env /root/.dotnet/tools tools
ENTRYPOINT ["/app/tools/web", "app/app.settings"]

The only other file that needs to change is to configure it to use your App's deployment settings:


# set environment variables used in and AWS task-definition.json:
export IMAGE_NAME=netcoreapps-rockwind-aws
export IMAGE_VERSION=latest

export AWS_DEFAULT_REGION=us-east-1
export AWS_ECS_CLUSTER_NAME=default

# set any sensitive information in travis-ci encrypted project settings:

Setup AWS ECS and Travis CI

After configuring your App deployment scripts you'll then need to Setup your AWS ECS with an EC2 instance to deploy to and Create your project in Travis CI. You'll then need to add your AWS Account details in the Travis CI project using Secure Environment Variables to store your AWS_ACCOUNT_ID, AWS_ACCESS_KEY and AWS_SECRET_KEY as well as any sensitive info and connection strings your App uses.

Let us know what you create!

We hope you're excited about these new features as we are and can't wait to see what you build with them - please share them with us so we can include it in the App Gallery and make it easy for everyone else to discover and use.

made with by ServiceStack