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.
Trending in Guides/Tuts
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
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
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 10 of 74 Posts!
juhalehtonen
Hey! Just wanted to drop a quick note saying thanks for the write-up
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.
jswny
Awesome! I’m Glad that you found the guide useful! I look forward to hearing your comments
jswny
Just added another section on how to (kind of) hot upgrade the server container without touching the database container. This should be pretty useful to people using this kind of Docker configuration because being able to swap out containers individually when your app changes is a huge advantage.
nelson687
Hey, I’ve been following this guide, but can’t make it work, I’m not using a database, just using a genserver to store data, so I skipped all the DB parts, also don’t want to use nginx. So I got to this point:
and everything seems to be fine, I can see some logs from the app, but I can’t access from the browser, tried 0.0.0.0:5000 but can’t see anything, the only thing I added was:
ENV PORT=4000in Dockerfile.run, as I’m using phoenix 1.3, is there anything I’m missing?idi527
So you are listening on 4000, but mapping
-p 5000:50005000 to 5000? I don’t think that would work.You can try changing either
ENV PORT=4000toENV PORT=5000or-p 5000:5000to-p 4000:5000(which would map tcp port 4000 in the container to port 5000 on the host).nelson687
Tried with that and rebuilt everything but still can’t access, is it right to try to access on my mac on
0.0.0.0:5000? I’ve changed the phoenix port to 5000 by addingENV PORT=5000and using the param-p 5000:5000on docker run. I’m running this on my mac as a host machine.idi527
I’ve followed the tutorial up to
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.exsOtherwise 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.shthe release.EDIT:
server: trueis 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?
OvermindDL1
If accessing it locally you instead want
http://127.0.0.1:5000for note.jswny
Thanks for reading! That should work. If you have
ENV PORT=5000in yourDockerfile.runand you are running the container with-p 5000:5000you should be able to access it from your host machine onlocalhost:5000or127.0.0.1:5000.I would make sure that you completely rebuild everything by deleting all of the images first just so you know Docker isn’t using any cached stages. You can do this with
docker rmi myapp-build myapp-release.However, I think at that stage in the guide you still won’t be able to run the server because you haven’t changed the config which is not explained until step 7. I will try and update the guide accordingly so that running things manually comes after that.
Last Post!
jswny
I haven’t worked on Phoenix apps in a long time, so this hasn’t been updated in a while unfortunately.