johninvictus
Deploy docker to digital ocean
I have followed this tutorial A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3. · GitHub
successifully but I have no idea how to deploy the result container to digital ocean.
Please help.
Most Liked
Exadra37
Using Ubuntu or any other normal Linux distro is not the best approach, once you are running containers you want to use an Operating system specific for that… I said CoreOS because is very easy to deploy in Digitall Ocean.
Another alternative is to use SmarOS but not sure id Digital Ocean has already templates to build droplets for it.
Doing this just for fun is ok, but for real production use cases should be avoided.
I definitely will read you approach and try to see in what differs from mine so that I can learn and improve my knowledge about build Elixir releases.
My Current Approach
When developing in Elixir I use a 100% Docker workflow with this Elixir Docker Stack.
When I want to deploy to my server I just build the release with this Docker Image in my laptop and then I push the Docker Image to the Gitlab private registry for containers. Afterwards in my CoreOs server I just use a Docker Compose file to run the Elixir App with volumes mapping to the host for secrets and persistence.
By now this Elixir Docker Stack is a work in progress and my releases are not for real production use cases, they are just for fun and learning purposes.
My Future Approach
My future goal is to build and release from a Gitlab CI pipeline using the Gitlab Container Registry and maybe their Auto DevOps workflow that will include the use of Kubernetes.
For now my priority is to learn to properly code in Elixir and leverage the OTP way of doing things, thus I will leave this approach of auto deployments for later, but I am keening to learn more about deploying Elixir Apps, thus I hope that more developers jump in and share their way of doing it.
Exadra37
Try to create a droplet with CoreOS template in Digital Ocean.
CoreOS is a specialised Operating System to run containers, thus Docker is supported out of the box.
I have note read the gist, thus I cannot tell you exactly the docker command, but if the gist has it than you should only need to run it on the droplet shell. This assumes that the Gist tells how to create the docker image and how to upload it to a private registry.
If not you can always use the Gitlab private registry for containers Introducing GitLab Container Registry and if you want to go further you can use their Auto DevOps for automated deployments as per https://docs.gitlab.com/ee/topics/autodevops.
jswny
Hi, author of the tutorial here, glad you enjoyed the guide! I actually use this strategy on my own $20 DigitalOcean droplet. If you have a lower tier droplet, you might not be able to build the release on the server since Distillery needs a fair bit of memory to build. That is why the guide specifically allows building the release on your development (local) machine and then running the resulting release on the actual deployment machine.
So, you have two options:
- Build and run the release on your droplet
- Build the release tarball on your local machine and then run it by building the runnable container on the droplet
Either way, I didl’t really write up anything on moving the actual resulting container/image to your droplet. That’s probably possible, but I’m not well versed in it.
The way I do it is that I just build the release and immediately run it on the droplet itself because mine can handle it. So, I just git pull the code onto the droplet, run build.sh to build the release (a tarball will be generated in the _build folder), and then run docker-compose up to run your app! Basically, that’s how iI do it and it looks like that’s what you tried also. Really, its fine for a basic setup. Again, Docker definitely has ways of pushing the built image up from your dev machine and then pulling it down onto the droplet to deploy it, but I haven’t looked into it much yet.
Let me know if you have any questions! ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








