jswny

jswny

Flexible Dockerized Phoenix Deployments (1.2 & 1.3)

Hello everyone, I recently redesigned my entire deployment process for Phoenix apps based on Docker. I really like the strategy that I came up with and it’s working very well for me so far. I have a new VPS which I’ve vowed to only install Docker on, and this strategy is perfect for my goal.

In addition, my strategy is optimized for:

  • Running multiple apps on the same server
  • Being compatible with deployment of any other kind of app (not just Elixir/Phoenix)
  • Compilation completely separate from deployment so you can compile anywhere and deploy anywhere else

In the interest of helping others who might be struggling with the same thing, I’ve documented my entire process in a Gist. I would love to contribute to this wonderful community on what seems to be one of the most popular difficulties when it comes to Phoenix (deployment).

Please let me know if you have any thoughts. The post is here: Flexible Dockerized Phoenix Deployments.

Most Liked

idi527

idi527

I’ve followed the tutorial up to

docker run --rm -it --name myapp-server -p 5000:5000 myapp-release foreground

and it hasn’t mentioned that you should uncomment one of the lines below in order for “phoenix in a release” to work.

config/prod.exs

# ## Using releases
#
# If you are doing OTP releases, you need to instruct Phoenix
# to start the server for all endpoints:
#
config :phoenix, :serve_endpoints, true # <--- here
#
# Alternatively, you can configure exactly which server to
# start per endpoint:
#
#     config :test, TestWeb.Endpoint, server: true

Otherwise cowboy is not started. AFAIK it is not uncommented by default so as not to start cowboy on any other task like phx.digest.

Maybe that’ll help you. Don’t forget to re./build.sh the release.


EDIT: server: true is mentioned later in section 7. :+1:

emoragaf

emoragaf

Thanks for putting this guide up. I have some questions about other options in the release building process, and the docker-compose setup.

  1. Have you looked at generating the release tarball using multi-stage builds rather than your current build script?

  2. Shouldn’t the db service in the docker-compose be using a volume for the data in case the container dies?

michalmuskala

michalmuskala

You need to add ecto_sql to the @start_apps list.

juhalehtonen

juhalehtonen

Hey! Just wanted to drop a quick note saying thanks for the write-up :slight_smile:

I followed the guide last night and everything seemed to work fine. I’ll perform some tests and alterations and will comment back further if I find anything specific to talk about.

idi527

idi527

They can also serve as a cache for dependencies, compiled PLT for dialyzer (for dependencies) and probably some other things that don’t change often too.

Where Next?

Popular in Guides/Tuts Top

sergio
Hey there, we’re going to walk through deploying a Phoenix app to a DigitalOcean droplet, manually - no tools no nothing. Just straight u...
New
sergio
Wrote this guide on how to integrate DropzoneJS with Phoenix Liveview. Hope it helps someone out! https://sergiotapia.com/dropzonejs-dir...
New
smpallen99
Did you know that IO.inspect/2 returns the the first argument and accepts a label option as a second argument. This makes it a perfect to...
New
cheerfulstoic
I spent quite a bit of time trying to find a good configuration to build / test my Elixir app in CircleCI and then push an image to Docke...
New
jtormey
Hello! Having written a lot of LiveView code, I’ve made some VS Code snippets to speed up writing callbacks for LiveViews and LiveCompon...
New
TwistingTwists
This is a thread to note down things/best practices encountered in LiveBeats App as I explore the source code. Found this usage of r...
New
f0rest8
Hi everyone, Just wanted to say that the new Self-referencing many to many guide is now up on the official Hex docs (at least I just not...
New
alejandroErik
POST IN CONSTRUCTION Process for compile erlang otp 20 with odbc-unix for Oracle connections on Solaris 11.3 for 64 bits: Introductio...
New
AstonJ
This blog post hit my timeline earlier, and I’ve also been learning about some fantastic Elixir related tips via @pragdave’s new online c...
New
dennisreimann
I wrote a guide for implementing Passwordless Authentication a.k.a. "Magic Login Links": Feedback welcome!
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement