gmile
After docker released native support for multi-stage builds, I decided to make my own small docker container with app.
Below container is based on the one from @bitwalker. It is the smallest one I could come up with in one sitting, given quite limited knowledge of docker & distillery releases:
# Dockerfile
FROM bitwalker/alpine-elixir:1.4.4 as builder
ADD . /app
WORKDIR /app
ENV MIX_ENV=prod
RUN mix do deps.get, deps.compile, release
FROM alpine:3.6
RUN apk add --no-cache \
ca-certificates \
openssl-dev \
ncurses-dev \
unixodbc-dev \
zlib-dev
WORKDIR /app
COPY --from=builder /app/_build/prod/rel/ritm/releases/0.0.1/ritm.tar.gz /app
ENV PORT=4000
RUN tar -xzf ritm.tar.gz; rm ritm.tar.gz
CMD ["bin/ritm", "foreground"]
It’s around 64Mb when pushed to docker hub. That’s a lot, although I don’t expect this to grow significantly (more app code & deps shouldn’t contribute that much).
I am aware guys from @Nerves-Core-Team build super-small linux images with the app installed, but I am not sure what could be derived from their work in order to build my own small container with docker.
How can I reduce the size of container even further?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 26 to 17- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
gmile
@melpon unfortunately by default erlang for alpine is built using
--enable-ssl=dynamic-ssl-lib–https://github.com/alpinelinux/aports/blob/master/community/erlang/APKBUILD#L90
melpon
I think
opensslpackage is not needed if Erlang is built with./configure --disable-dynamic-ssl-lib ....gmile
So, the Dockerfile I’m using has changed significantly. I’m now using two of them:
This is how they look like:
Base:
Everyday use:
In order to build this, I run:
I could merge both Dockerfiles, but it just didn’t make sense to re-install the compile-time dependencies every time I needed to build the app. After all, elixir and erlang release versions much less frequently.
gmile
In case anyone is interested, this is the container I’m building right now. It uses:
alpine:3.6as a builder/runner image,Erlang 20.1.1Elixir 1.5.2I like to build my own image instead of a pre-backed image in this case. I like to install elixir/erlang, as well as other packages, instead of compiling them. By looking at base image, I know that there’s no magic going on here.
It’s size, including my apps compiled code and dependencies is 55.5 Mb.
I’m relying on distillery for building releases. After the container is built, the app must be started by running
bin/my_app foregroundin the container:asaaki
A simple hello world Elixir app without any real code and deps would be around 10ish MB with stripping.
Though I also wouldn’t recommend using stripping and/or zipping if not really necessary, of course.
bitwalker
Your ERTS is only 19mb though, of which 11mb is apparently debug info, the rest is presumably system libs and your application code. 20mb is the absolute smallest application people are reporting, not the average. My applications on average are ~50-75mb, so you are well within normal size in my opinion.
gmile
Even if I strip 11 Mb, that’d make it 48 - 11 = 37, which is still 2x times than what people here are reporting, e.g. 20 Mb.
I’ll investigate further.
bitwalker
Yeah I dug around in my
alpine-erlangbuild today, it looks like the bulk of the extra space inbeam.smpis in the.debug_locand.debug_infosections of the binary (~11mb) - so I assume one could strip those easily enough, but whether that’s ideal or not is a different question I suppose.DianaOlympos
I still need to push some PR, and tbh, the new docker multi stage support nearly kill the need for edib.
gmile
I didn’t know about edib, thank you!