Deployment
Deploy API
First we need to create a Release build of your API. Run these commands on your machine:
cd src/ShipDotnet.Api
dotnet publish --configuration Release --runtime linux-x64 --self-contained true --output ./publish -p:DebugSymbols=false
Quick reference:
-- configuration
- sets it as Release which excludes bunch of things not needed to run (but needed to debug).
--runtime
- here you can pick linux, windows or mac
--self-contained
- this avoids installing dotnet framework on the server
--output
- where the production ready output goes
Now you can upload the content of publish directory to your server, using sftp (scp is great for that).
scp -r ./publish user@your-ubuntu-ip:/var/www/apps/shipdotnet-api
Make our API executable
chmod +x /var/www/apps/shipdotnet-api/ShipDotnet.Api
Let's test it:
cd /var/www/apps/shipdotnet-api/
./ShipDotnet.Api
You should see the output:
[17:05:27 INF] Now listening on: http://localhost:5000
[17:05:27 INF] Application started. Press Ctrl+C to shut down.
[17:05:27 INF] Hosting environment: Production
[17:05:27 INF] Content root path: /var/www/apps/shipdotnet-api
Hit Ctrl + C to quit the process.
In the next sections we will see how to get it up and running
Next:
Run Api