Astolfo
When generating a release with phx.gen.release --docker a debian version is used by default to avoid “DNS issues” on Alpine.
It seems like the mentioned issues have been resolved in Alpine 3.18:
- DNS because of musl/Alpine base? · Issue #138 · nicolaka/netshoot · GitHub
- Debugging DNS Resolution | Kubernetes
Because Alpine images are much smaller, and as far as I’m aware have fewer vulnerabilities.
I suggest either switching to alpine by default or adding an option to generate Dockerfile that uses alpine as a base image (like phx.gen.release --docker --alpine).
If the community agrees, I can work on a pull request.
Thank you,
Anna
Trending in Proposals: Ideas
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
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
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex











First 10 of 10 Posts
LostKobrakai
While DNS might have been a truely blocking issue I still wouldn’t call alpine a great option for a default. People will eventually add a NIF based dependency where runing musl has a high likelyhood of breaking things.
Personally I also don’t understand the obsession with image size given docker caching that stuff anyways.
Astolfo
There are many reasons to prefer smaller images:
Are you sure there are that many popular libraries that don’t work with musl? Could you provide some examples?
hauleth
I think that this:
May be problematic WRT some NIF code.
But honestly I do not think that the difference is meaningful:
Astolfo
I’ve recently moved one of my real production apps from debian:12-slim to alpine the result was a 70% reduction in size (131MB → 37MB) (I don’t have bash in my container - why would I?
phx.gen.releaseusessh)Astolfo
As far as I’m aware it doesn’t seem to be an issue for other projects in docker/kubernetes ecosystem.
Maybe my understanding is limited, but I don’t know any real examples of issues with that. Could you please provide some examples?
mwilsoncoding
I originally agreed that it would be nice to have options in the generator to customize the variant. My work asks me to ship alpine images where possible, so it’s a frequent concern.
For example, the following could explicitly generate the current state/default:
--variantcould specify the OS variant to base your build/run on and--variant-versionits version.Then again, it seemed easy enough to tweak the default
Dockerfileto support all three OS options. But with this solution, I’m back to not needing new options in the generator.Only 2 meaningful changes. First toward the top:
Here, we:
VARIANTbuild argDEBIAN_VERSIONtoVARIANT_VERSIONdebianto${VARIANT}RUNacasestatement to toggle OS package manager setup commands based on the value ofVARIANTThen toward the end of the file:
Here, we:
casestrategy to set up OS deps on the runner imageMUSL_LOCPATHMUSL_LOCPATHand perform remaining locale setup command for ubuntu/debianI’ve adapted the above solution from this post for setting up the locale in alpine. Tho this post directed me to
musl-locales-langoverlang.To get the various image types:
Available options for
VARIANTandVARIANT_VERSIONwere found by browsing the available tags on Dockerhub.Your mileage may vary, but this at least works for me on a freshly generated LiveView app using Elixir 1.18.3 on OTP 27.3.
Astolfo
I’d prefer a leaner interface without unnecessary options like
--elixir-versionand others, because you can easily change that in theDockerfileitself. So something likemix phx.gen.release --docker --docker-base=debianDon’t you think that’s an unnecessary complication? I think in the vast majority of cases there is no need to support multiple base images in one dockerfile. I think it’s better to generate simpler dockerfiles that support only one base image (which one will depend on
--docker-baseoption)mwilsoncoding
I can get behind that idea. The other flags felt like optional convenience flags for overriding the default versions written into the dockerfile, but there’s no real need for them, since you can override them at
docker buildtime using the build args.I agree. The
casestatements, tho they will work here, are ugly to look at and are arguably error-prone to maintain over time. To be clear, I straight-up replace the debian default and its package management setup with alpine equivalents when it comes to production. A flag to generate it from the onset would be lovely. Either the Dockerfile itself supports multiple bases or the generator does; and I do prefer simpler dockerfiles.I’m not sure it should be the default, but I do think a large portion of the community would appreciate a built-in option to generate an
alpinebased image, or evenscratchif possible.IMO, the lower CVE count out-of-the-box for container workloads is worth it being the default (with anyone running into NIF issues then swapping to debian or ubuntu when they run into such problems), but a flag would suffice.
egze
+1 for alpine support. While it’s not a big deal and I usually just copy/paste the Dockerfile from previous project - I do prefer to have a smaller image. Never had a problem with it in more than 5 years.
chulkilee
Debian seems like a"good enough" default for me. It would introduce little barrier to new users running it in a Linux container. If we want to optimize further - why not choosing scratch or distroless? (Yeah I wanted it with Bazel - Elixir and Bazel (Google’s open-sourced monorepo build system) )
If there are strong reasons to use Alpine as the default, it might be better to make it the only option (as Debian currently is), rather than supporting multiple base images - which could be add extra maintenance overhead.
@ericmj I just noticed that hexpm/bob recently switched its Dockerfile base image from Alpine to Debian. Could you share what motivated the change? Was it related to GitHub Actions? Alpine => Debian and updates by ericmj · Pull Request #204 · hexpm/bob · GitHub