Production deployment on Digital Ocean Apps
Written by Miguel Michelson
There are many ways to deploy chaskiq on the cloud. This article is about the deploy of Chaskiq's Docker image on DigitalOcean. Note that this procedure will be similar on other cloud providers, K8s context and so.
Chaskiq has two databases that is has to be connected, that's Redis and Postgres. So, the easiest way, if you don't have databases already, is to create that on the managed databases section on DigitalOcean. Please check the details before proceed: https://www.digitalocean.com/products/managed-databases/ when you have the databases you will need the string connection information for both: the format is like this:
You will need to fork the chaskiq repo for deployment, note that this is not the main Chaskiq repo, instead is a special repo with just the Dockerfile on it. repo is located here.
Then, go to https://cloud.digitalocean.com/apps/new , and select your forked github repository. when you are at step 3 of 4 you will be asked for some details.
App type: The configuration if it's all good will detect a Docker application:
The run command you have to configure is:
bundle exec rails s -b 0.0.0.0 -p 3000
The HTTP port has to be the same as the port in the build command, so put port 3000. Environment Variables:
Make sure you put the proper environment variables on the prompt, but don't worry you could also edit this later. Check the Chaskiq environment variables article.
When you are done, hit next and the app will be built in a minute.
Chaskiq does some background tasks in order to not block the web process with heavy tasks like emails, file uploading and messaging, The process that handles all the work is a Sidekiq server that has to be installed to, This are different as web apps because they don't receive internet traffic, they just receive instructions internally to perform tasks.
Once you got the Web app working you will need to add Sidekiq as an App Worker component. So, in the DO app panel go to components and add a worker.
The process is simple, just add the Worker components and choose the same repo for the worker. Also you will have to put the same ENV vars as your web process. The only difference is that you have to set a different start command, the start command is:
bundle exec sidekiq -C config/sidekiq.yml
Digital ocean will give you an standard domain, that will end with the .ondigitalocean.app , that's good enough to get started, precisely because it has SSL support. But you can also set your own domain to the instance, just make sure to change the HOST and WS env vars.