×
Back to book

C#Bot Deployment Notes

This article will show you how to deploy your C#Bot application.

1. Prepare Application

a) Change directory into your [projectName]/serverside/src directory.

b) Run dotnet publish -c Release

2. Prepare Deployment Artefact

a) Prepare the docker file i.e Dockerfile It's contents should take the form

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

ENV "ServerSettings__ServerUrl" "https://beta.domainName.com.au" 
ENV "ConnectionStrings__DbConnectionString" "Server=[DATABASEHOSTNAME];Database=[DATABASE];Username=postgres;Password=[PASSWORD]" 
ENV "CertificateSetting__JwtBearerAuthority" "https://beta.domainName.com.au" 
ENV "ASPNETCORE_URLS" "http://0.0.0.0:80" 
# Beta mail trap ENV "EmailAccount__Host" "smtp.mailtrap.io" 
ENV "EmailAccount__Username" "2702293ad75c53" 
ENV "EmailAccount__Password" "xxxxxx" ENV "EmailAccount__FromAddress" "fromaddress@example.com" 
ENV "EmailAccount__FromAddressDisplayName" "example" 
ENV "EmailAccount__Port" "2525" 

EXPOSE 80 
WORKDIR /usr/src/app/ 
COPY ./[PROJECTNAME].App/ ./ 
ENTRYPOINT ["dotnet", "[PROJECTNAME].dll"] 

b) Copy your application artefacts into the same directory as your Dockerfile. You can find this [projectName]/serverside/src/bin/Release/netcoreapp3.1/publish. You should find a collection of files.

c) Build your image by running the following in the same directory as your dockerfile docker build . -t [projectName]/[version]

3. Deploy

a) Copy your new image to your deployment target either by pulling the docker image we created in the previous step or by copying and building the image as shown in step 2.

b) Run your new artefact with docker run [projectName]/[version]