C#Bot Deployment Notes
Step 1: Prepare Application
- Change directory into your
[projectName]/serverside/src
directory. - Run
dotnet publish -c Release
Step 2: Prepare Deployment Artefact
-
Prepare the docker file i.e
Dockerfile
It’s contents should take the formFROM 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"]
-
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. -
Build your image by running the following in the same directory as your dockerfile
docker build . -t [projectName]/[version]
Step 3: Deploy
-
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.
-
Run your new artefact with
docker run [projectName]/[version]
Was this article helpful?