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
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. ![]()
emoragaf
Thanks for putting this guide up. I have some questions about other options in the release building process, and the docker-compose setup.
-
Have you looked at generating the release tarball using multi-stage builds rather than your current build script?
-
Shouldn’t the db service in the docker-compose be using a volume for the data in case the container dies?
michalmuskala
You need to add ecto_sql to the @start_apps list.
Popular in Guides/Tuts
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
- #code-sync
- #javascript
- #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









