johninvictus

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

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

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

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:

  1. Build and run the release on your droplet
  2. 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! :slight_smile:

Where Next?

Popular in Questions Top

gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New

We're in Beta

About us Mission Statement