How can I deploy/automate deploy my (hello-world rails app created by docker compose on my Macbook) to my Digital ocean droplet?

Posted December 15, 2016 4.5k views
Ruby on RailsDockerDeployment

There is no error to post.. I’ve implemented the Hello-world app via docker-compose on my laptop (Macbook pro). I want to follow a simple good approach to deploy it to Digital ocean and to automate this deployment (heroku-like).

Thanks in advance!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

I got one idea on my mind how you can do it.
Heroku is based on GitHub, you connect desired repo to it and you use however you want.

So we can do something like this. Idea is to look repo where you store code for changes, once you change something, pull it on the server.
Here comes Git Hooks. It has many features, but one of useful could be execute script on push. In script, instruct server to fetch changes.
How To Use Git Hooks To Automate Development and Deployment Tasks will help you understand how it works and how to make it. This tutorial should work for any Git based solution (e.g. GitHub, GitLab).

Beside Git Hooks, GitHub offers you Webhooks. Webhook will send HTTP POST request to your server once you do something in repo. You select which action you want to watch. This will require to set up app on server that will parse HTTP POST request. App can be in any language that can parse HTTP requests (e.g. Ruby (example on GitHub site is written in Ruby/Sinatra), JS/Node, Go…).

GitLab also has Webhooks which is handy if your prefer it over GitHub.

DigitalOcean doesn’t have Webhooks tutorial, but there is chance it appears. :)

You can combine this with Docker/Docker Compose if you want. This is not a needed step, above will work flawless without Docker, but if you want better management, go on Docker can be very helpful. I’ll leave you few DO resources that can help you get started:
How To Install and Use Docker on Ubuntu 16.04.
How To Install Docker Compose on Ubuntu 16.04.
Next one is excellent article, maybe it’ll give you some more ideas: How To Configure a Continuous Integration Testing Environment with Docker and Docker Compose on Ubuntu 16.04.

by Justin Ellingwood
Git is a very robust and mature version control system that has seen great adoption in recent years. One of git's great features is its ability to use "hooks" to call arbitrary scripts when certain git events occur. In this guide, we'll discuss the general idea behind git hooks, talk about how to work around some of its inconsistencies, and demonstrate some implementations that you can use in your development process.