## Deployment Process for APIs
* Before we begin, ```sudo apt update ```
* Install Golang from official website
* Setup env variables like GOPATH, GOBIN, go's executable path (/usr/bin/go/bin)
* add server's ssh key into repository for easy and credential-less cloning of repo
* Install dep for package management
* Install database (mongo) from official website, (v4.0+)
* set db auth, add line in /etc/mongod.conf saying
```
security:
authorization: enabled
```
* create mongo user specific to database being used by the app with random enough passwords (i use apg tool to good passwords)
* restart database (```sudo systemctl restart mongod```)
* install api dependencies with ```dep ensure```
* create a service file in ```/etc/systemd/system/env-api.service```
* fill in env variables for the api and path to executable
* this service file is very important, since we dont have a centralised logging mechanism in api, it helps with logs and if system restarts, it'll restart the api automatically, however it'll not restart the api if it crashes by panics in app or unhandled errors.
* install nginx and create a new file in ```/var/www/nginx.conf```, its by convention that i keep the file in this directory, could be anywhere.
* include the file in ```/etc/nginx/nginx.conf```
* setup the nginx config for api (proxy_pass) and for static file server
* install certbot from official website and simply run ```sudo certbot --nginx```
* then follow the wizard and it'll install the ssl certs and you'll have the api deployed with ssl and db authentication setup