blonk is a radar for your web, where you follow vibes for cool blips on the radar
at main 2.6 kB view raw
1# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian 2# instead of Alpine to avoid DNS resolution issues in production. 3# 4# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu 5# https://hub.docker.com/_/ubuntu?tab=tags 6# 7# This file is based on these images: 8# 9# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image 10# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20210902-slim - for the release image 11# - https://pkgs.org/ - resource for finding needed packages 12# - Ex: hexpm/elixir:1.14.0-erlang-25.0.4-debian-bullseye-20210902-slim 13# 14ARG ELIXIR_VERSION=1.16.0 15ARG OTP_VERSION=26.2.1 16ARG DEBIAN_VERSION=bullseye-20231009-slim 17 18ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}" 19ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}" 20 21FROM ${BUILDER_IMAGE} as builder 22 23# install build dependencies 24RUN apt-get update -y && apt-get install -y build-essential git \ 25 && apt-get clean && rm -f /var/lib/apt/lists/*_* 26 27# prepare build dir 28WORKDIR /app 29 30# install hex + rebar 31RUN mix local.hex --force && \ 32 mix local.rebar --force 33 34# set build ENV 35ENV MIX_ENV="prod" 36 37# install mix dependencies 38COPY mix.exs mix.lock ./ 39RUN mix deps.get --only $MIX_ENV 40RUN mkdir config 41 42# copy compile-time config files before we compile dependencies 43# to ensure any relevant config change will trigger the dependencies 44# to be re-compiled. 45COPY config/config.exs config/${MIX_ENV}.exs config/ 46RUN mix deps.compile 47 48COPY priv priv 49 50COPY lib lib 51 52COPY assets assets 53 54# compile assets 55RUN mix assets.deploy 56 57# Compile the release 58RUN mix compile 59 60# Changes to config/runtime.exs don't require recompiling the code 61COPY config/runtime.exs config/ 62 63COPY rel rel 64RUN mix release 65 66# start a new build stage so that the final image will only contain 67# the compiled release and other runtime necessities 68FROM ${RUNNER_IMAGE} 69 70RUN apt-get update -y && \ 71 apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \ 72 && apt-get clean && rm -f /var/lib/apt/lists/*_* 73 74# Set the locale 75RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen 76 77ENV LANG en_US.UTF-8 78ENV LANGUAGE en_US:en 79ENV LC_ALL en_US.UTF-8 80 81WORKDIR "/app" 82RUN chown nobody /app 83 84# set runner ENV 85ENV MIX_ENV="prod" 86 87# Only copy the final release from the build stage 88COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/elixir_blonk ./ 89 90USER nobody 91 92# If using a startup script, copy it over 93# COPY --from=builder --chown=nobody:root /app/bin/server /app/bin/migrate ./bin/ 94 95CMD ["/app/bin/server"] 96