Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library working in dev but crashes in a docker release #254

Closed
froy001 opened this issue Jul 22, 2020 · 4 comments
Closed

Library working in dev but crashes in a docker release #254

froy001 opened this issue Jul 22, 2020 · 4 comments

Comments

@froy001
Copy link

froy001 commented Jul 22, 2020

I have open_api_spex working in development.
My application is an API only phoenix application

In production I am using mix release and docker. The dockerfile is given below:

# ---- Build Stage ----
FROM erlang:22-alpine AS app_builder

# Set environment variables for building the application
ENV MIX_ENV=prod \
    TEST=1 \
    LANG=C.UTF-8

# Fetch the latest version of Elixir (once the 1.9 docker image is available you won't have to do this)
RUN set -xe \
  && apk add curl make gcc build-base --update-cache \
  && ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/v1.10.4.tar.gz" \
  && ELIXIR_DOWNLOAD_SHA256="8518c78f43fe36315dbe0d623823c2c1b7a025c114f3f4adbb48e04ef63f1d9f" \
  && curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL \
  && echo "$ELIXIR_DOWNLOAD_SHA256  elixir-src.tar.gz" | sha256sum -c - \
  && mkdir -p /usr/local/src/elixir \
  && tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz \
  && rm elixir-src.tar.gz \
  && cd /usr/local/src/elixir \
  && make install clean

# Install hex and rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# Create the application build directory
RUN mkdir /app
WORKDIR /app

# Copy over all the necessary application files and directories
COPY config ./config
COPY lib ./lib
COPY priv ./priv
COPY rel ./rel
COPY mix.exs .
COPY mix.lock .

# Fetch the application dependencies and build the application
RUN mix deps.get
RUN mix deps.compile
RUN mix phx.digest
RUN mix release

# ---- Application Stage ----
FROM alpine AS app

ENV LANG=C.UTF-8

# Install openssl
RUN apk update && apk add openssl ncurses-libs postgresql-client && \
  rm -rf /var/cache/apk/*

# Copy over the build artifact from the previous step and create a non root user
RUN adduser -h /home/app -D app
WORKDIR /home/app
COPY --from=app_builder /app/_build .
RUN chown -R app: ./prod
USER app

COPY entrypoint.sh .

# Run the Phoenix app
CMD ["./entrypoint.sh"

When trying to access any of the endpoints after building and deploying the docker image I am getting the following error which I don't understand:

2020-07-22T06:37:44.953317157Z Request: GET /api/swaggerui
2020-07-22T06:37:44.953321116Z ** (exit) an exception was raised:
2020-07-22T06:37:44.953325320Z     ** (MatchError) no match of right hand side value: {:error, :chunk_not_found}
2020-07-22T06:37:44.953329616Z         (open_api_spex 3.7.0) lib/open_api_spex/controller.ex:155: OpenApiSpex.Controller.get_docs/2
2020-07-22T06:37:44.953345169Z         (open_api_spex 3.7.0) lib/open_api_spex/controller.ex:139: OpenApiSpex.Controller.__api_operation__/2
2020-07-22T06:37:44.953349441Z         (open_api_spex 3.7.0) lib/open_api_spex/path_item.ex:77: anonymous fn/1 in OpenApiSpex.PathItem.from_valid_routes/1
2020-07-22T06:37:44.953352924Z         (elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
2020-07-22T06:37:44.953356690Z         (open_api_spex 3.7.0) lib/open_api_spex/path_item.ex:76: OpenApiSpex.PathItem.from_valid_routes/1
2020-07-22T06:37:44.953360553Z         (open_api_spex 3.7.0) lib/open_api_spex/paths.ex:23: anonymous fn/1 in OpenApiSpex.Paths.from_router/1
2020-07-22T06:37:44.953363975Z         (elixir 1.10.4) lib/enum.ex:1400: anonymous fn/3 in Enum.map/2
2020-07-22T06:37:44.953367679Z         (stdlib 3.12.1) maps.erl:232: :maps.fold_1/3

I am not sure what to do with this error. Would appreciate any help

@velimir
Copy link
Contributor

velimir commented Jul 22, 2020

I think this is related to #242.
As a workaround you can try to use distillery until the Elixir with the fix is released.

@froy001
Copy link
Author

froy001 commented Jul 22, 2020

@velimir thanks. I will look into it.

distillery is a hassle I'd rather not go through :).

@velimir
Copy link
Contributor

velimir commented Jul 22, 2020

Alternatively you can build Elixir from the HEAD and give the new :strip_beams a go.

@mbuhot
Copy link
Collaborator

mbuhot commented Jul 23, 2020

Yes in the short term you'll need to disable beam stripping for your release.

@mbuhot mbuhot closed this as completed Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants