I have a docker file with two stages which successfully builds locally. When I attempt to push it to the heroku's container service it fails to build with an error that a file is not available.
Error
** (Mix.Config.LoadError) could not load config config/prod.exs
** (ArgumentError) argument error
:erlang.binary_to_integer("")
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
(stdlib) erl_eval.erl:236: :erl_eval.expr/5
Dockerfile
FROM bitwalker/alpine-elixir-phoenix:1.5.2 as builder
ARG CLOAK_ENCRYPTION_KEY
ARG DATABASE_URL
ENV MIX_ENV=prod PORT=$PORT DATABASE_URL=$DATABASE_URL CLOAK_ENCRYPTION_KEY=$CLOAK_ENCRYPTION_KEY
WORKDIR /app
# Cache elixir deps
ADD mix.exs mix.lock /app/
RUN mix do deps.get, deps.compile
# Same with npm deps
ADD client/package.json client/package-lock.json /app/client/
RUN cd client && \
npm install
ADD . .
# Run frontend build, compile, and digest assets
RUN cd /app/client/ && \
npm run build && \
cd /app && \
mix do compile
RUN MIX_ENV=prod mix release --env=prod --verbose --no-tar
### Release
FROM alpine:3.8
# We need bash and openssl for Phoenix
RUN apk upgrade --no-cache && \
apk add --no-cache bash openssl
ENV SHELL=/bin/bash
COPY --from=builder /app/_build/prod/rel/myapp/app
ENTRYPOINT ["/app/bin/myapp"]
CMD ["foreground"]
The error occurs at the second mix do compile
What cause this to work locally, but fail on Heroku?
Figured it out. When executing the heroku push i was doing an --arg
param for each argument (Docker --build-arg
is 1 to 1). Heroku actually only wants one --arg
with all arguments concatenated with a comma.
The heroku equivalent of
docker build -t myapp --build-arg DATABASE_URL=someurl --build-arg CLOAK_ENCRYPTION_KEY=somekey
is
heroku container:push web --arg DATABASE_URL=someurl,CLOAK_ENCRYPTION_KEY=somekey