Deploying a Golang app on Linux Server
This post lists the steps to get a golang app running on a linux server
I am writing a recommendation engine in Golang and wanted to put up the initial version on the web. Hence this post. Please note that this may not be the recommended way. Quick and Dirty is the key phrase here.
- Get a VPS. I got one from Digital Ocean. Use this referral link to get some free credits for you and me.
- Secure the VPS(relatively speaking). Since my server was running Ubuntu, I followed this tutorial
- Cross compile your golang for the target OS and Architecture. More info here. More info here regarding OS and ARCH.
- SCP the executable
- SCP any other assets required. In my case, I keep all assets inside a folder called static and htmls in a folder called templates so
- Since I am using RethinkDB, it needs to be installed. More info here
- You may want to run RethinkDB as a service
- Run the binary. You may want to run it with nohup so that the process stays alive even after your session. Remember, quick and dirty. There are other better ways to do this.
Access it at http://[ip]:[port]
Stop the process