Docker image build for umbrella app gets stuck at esbuild download

I want to build a docker image for a release of an umbrella phoenix app, but get stuck at installing esbuild:

#24 [build 14/20] RUN mix esbuild --no-runtime-config default --minify
#24 1.204 10:00:19.345 [warning] esbuild version is not configured. Please set it in your config files:
#24 1.204 
#24 1.204     config :esbuild, :version, "0.17.11"
#24 1.204 
#24 1.211 
#24 1.211 10:00:19.354 [debug] Downloading esbuild from https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.11.tgz

Two things are surprising me here:

  1. I have set up the esbuild version my config/config.exs file and therefore do not understand the warning.
    config :esbuild,
      version: "0.17.11",
      ...
    
  2. When opening the download link in my browser, the download is done almost immediately. However, in the docker build process, nothing seems to happen. I have tried multiple times and waited up to 15 minutes for the download.

As a test, I run a docker build for a previous, non-umbrella project, and all worked well.
Have you run into this before or have an idea, what the cause may be?

Dockerfile
FROM elixir:1.15-alpine AS build

# prepare build dir
WORKDIR /app

# install hex/rebar package managers
RUN mix local.hex --force && \
    mix local.rebar --force

# Pulls in build packages required to build NIFs for bcrypt_elixir
RUN apk add build-base

# GIT is required for some github project dependencies
RUN apk add git
ARG GITHUB_USERNAME
ARG GITHUB_TOKEN
RUN git config --global url."https://$GITHUB_USERNAME:$GITHUB_TOKEN@github.com/".insteadOf "https://github.com/"

ENV MIX_ENV=prod

# Copy mix files that contain dependency lists. We do this separately to be able to cache deps between builds.
COPY mix.exs .
COPY mix.lock .
COPY apps/my_app/mix.exs apps/my_app/mix.exs
COPY apps/my_app_web/mix.exs apps/my_app_web/mix.exs

# install and compile mix dependencies
RUN mix deps.get --only prod
RUN mix deps.compile

# Digest assets
COPY apps/my_app_web/priv apps/my_app_web/assets apps/my_app_web/
RUN mix esbuild --no-runtime-config default --minify
RUN mix phx.digest

# Copy and compile apps
WORKDIR /app
COPY apps/my_app/lib apps/my_app/priv apps/my_app/test apps/my_app/
COPY apps/my_app_web/lib apps/my_app_web/test apps/my_app_web/mix.exs apps/my_app_web/
RUN mix compile

# Build release
RUN mix release

# Build minimal runtime container wihtout build tools etc
FROM alpine:3.18 AS app

# Required for Erlang
RUN apk add --no-cache openssl ncurses-libs libgcc libstdc++

WORKDIR /app

COPY --from=build /app/_build/prod/rel/my_app_umbrella ./
COPY --from=build /app/bin ./bin
ENV HOME=/app

EXPOSE 4000

CMD bin/my_app_umbrella start

Might not be the answer that you’re after – but why don’t you just install esbuild with apk inside the container?

1 Like

You don’t copy configs.

RUN mkdir config
COPY config/config.exs config/${MIX_ENV}.exs config/
2 Likes

:man_facepalming:

Thanks.

Ye good idea, but with corrected configs it worked as intended.

1 Like