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

Segmentation fault on docker-compose up #295

Open
asfaltboy opened this issue Apr 29, 2024 · 5 comments
Open

Segmentation fault on docker-compose up #295

asfaltboy opened this issue Apr 29, 2024 · 5 comments

Comments

@asfaltboy
Copy link

I just checked out the repo, am on main branch, and can't start the app with docker-compose.

Here are the steps that I followed:

  1. gh clone repo azimuttapp/azimutt
  2. cd azimutt
  3. cp .env.example .env
  4. docker-compose up

Full error logs:

[+] Building 1.5s (18/38)                                                                                                                                                                       docker:desktop-linux
 => [backend internal] load build definition from Dockerfile                                                                                                                                                    0.0s
 => => transferring dockerfile: 3.97kB                                                                                                                                                                          0.0s
 => [backend internal] load metadata for docker.io/hexpm/elixir:1.14.3-erlang-25.2.2-debian-bullseye-20230109-slim                                                                                              1.0s
 => [backend internal] load metadata for docker.io/library/debian:bullseye-20230109-slim                                                                                                                        1.1s
 => [backend internal] load .dockerignore                                                                                                                                                                       0.0s
 => => transferring context: 4.95kB                                                                                                                                                                             0.0s
 => [backend builder  1/25] FROM docker.io/hexpm/elixir:1.14.3-erlang-25.2.2-debian-bullseye-20230109-slim@sha256:f8716e4a7fd1ee7a0da8219e3af7ffba01b3c231855d3008588f908491c0c778                              0.0s
 => [backend stage-1 1/8] FROM docker.io/library/debian:bullseye-20230109-slim@sha256:98d3b4b0cee264301eb1354e0b549323af2d0633e1c43375d0b25c01826b6790                                                          0.0s
 => [backend internal] load build context                                                                                                                                                                       0.1s
 => => transferring context: 104.97kB                                                                                                                                                                           0.1s
 => CACHED [backend builder  2/25] RUN apt-get update -y && apt-get install -y build-essential git nodejs npm curl wget && apt-get clean && rm -f /var/lib/apt/lists/*_*                                        0.0s
 => CACHED [backend builder  3/25] RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - && apt-get install -y nodejs                                                                                   0.0s
 => CACHED [backend builder  4/25] RUN npm install -g [email protected]                                                                                                                                                 0.0s
 => CACHED [backend builder  5/25] RUN wget -O - 'https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz' | gunzip -c >/usr/local/bin/elm                                          0.0s
 => CACHED [backend builder  6/25] RUN chmod +x /usr/local/bin/elm                                                                                                                                              0.0s
 => CACHED [backend builder  7/25] WORKDIR /app                                                                                                                                                                 0.0s
 => ERROR [backend builder  8/25] RUN mix local.hex --force &&     mix local.rebar --force                                                                                                                      0.3s
 => CACHED [backend stage-1 2/8] RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales && apt-get clean && rm -f /var/lib/apt/lists/*_*                                            0.0s
 => CACHED [backend stage-1 3/8] RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen                                                                                                               0.0s
 => CACHED [backend stage-1 4/8] WORKDIR /app                                                                                                                                                                   0.0s
 => CACHED [backend stage-1 5/8] RUN chown nobody /app                                                                                                                                                          0.0s
------                                                                                                                                                                                                               
 > [backend builder  8/25] RUN mix local.hex --force &&     mix local.rebar --force:
0.339 Segmentation fault
------
failed to solve: process "/bin/sh -c mix local.hex --force &&     mix local.rebar --force" did not complete successfully: exit code: 139
@loicknuchel
Copy link
Contributor

Oops... Will have to look into this...
Any additional info about your setup? (OS, version, installed libs...)
As it's working for other people, I guess it's related to a conflict somewhere.

@bratsos
Copy link

bratsos commented Jun 5, 2024

Same issue here. I'm on macOS 14.2.1 (M1 Pro), using OrbStack/buildkit. I'm not sure how else I can help, let me know if you have any questions!

@loicknuchel
Copy link
Contributor

Hi. Thanks for letting me know.
I don't have a Mac so not sure how to reproduce.

@MrKovar
Copy link

MrKovar commented Jun 19, 2024

So I think this is either an issue with Elixir images defaulting to supporting amd64 builds (e.g. This issue on the Elixir Forums) OR an Elm issue along the same vein. I'm currently doing some testing locally with different containers that would run with a new ARG to specify platform.

@MrKovar
Copy link

MrKovar commented Jul 2, 2024

Okay. I did a whole write-up about the issue and why I couldn't fix it and what needs to be done next. While writing it I figured out the issue and raised a PR: #311

Explanation of the issue:
Problem 1: Irrelevant to what your OS is, the Dockerfile still pulls in the Linux x64 version of the elm binary. Normally Docker is able to mitigate issues when you run in compatibility mode on M1 chips, but when you try to execute the elm binary you will get the segmentation fault. Normally you would be able to change the URL to download the ARM version instead but elm does not publicly distribute an arm binary specifically for Linux devices so replacing the wget line mentioned above would need to get a compiled binary elsewhere.

Solution 1: I thought about creating a pre-compiled binary and hosting it on Github, but ultimately went down the route of writing a new image that compiles the binary itself so that you could easily tie it into a Dockerfile or run it locally and copy the binary directly to your system. It seemed to be more beneficial in the long run once the image is on your system.

Problem 2: The elm-coverage devdependency has [email protected] as a sub-dependency which will reach out to npm to get the package, realize you are on an arm device and crash with a message detailing that there are no arm binaries available to download - can be seen on Line 73 in the install.js file of the npm package.

Solution 2: Unfortunately the only thing that worked for me was to remove the dependency altogether. A developer with more pnpm experience should be able to create a local npm link to prevent elm-coverage from reaching out to npm, but I figured a "prod" environment sooner rather that later would be better for everyone wanting to use this.

Best of luck!

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

4 participants