Elm in Docker, elm binary apparently corrupted

I have a Rails/webpack/Elm app working perfectly on OS X giving me huge headaches in my docker images. For some reasons the elm binary is corrupted/broken and I really have no idea what to do to fix this.

This is the output I have when docker-compose up

Here is my Dockerfile

and here various versions - elm 0.19, webpacker 4

I’ve tried all the typical stuff, from updating everything to deleting elm-stuff

Does anybody have any idea about this?

TIA, ngw

One thing I had to take care of when using Docker with 0.19 was to make sure that my local elm-stuff does not get copied over to the container, by specifying it in .dockerignore. I was getting the error about “corrupted” packages, which echoes the title. However, I did not spot this error in the printout provided above, so it might not apply here.

I haven’t fully processed the setup to be able to debug further atm, but maybe someone else has had a similar setup and they know better :slight_smile:


I think this line is saying the the elm binary does not exist?

Error: spawn /usr/src/directory/node_modules/elm/unpacked_bin/elm ENOENT

I would be tempted to create a docker container for the image, then open a shell inside it and check if elm is there at the location described in the error message. Is there some extra step you need to run to get elm installed?

It looks to me like the step you are expecting to install Elm is:

yarn install

? But that would, if anything be a local install, not under /use/src/…

well spotted!

So, since npm does not host binaries, and Elm is not really a node package, we host the binaries on github releases and use a shim script to get everything into the right places at the right times. That error says that the final binary isn’t in the right place. There are two things I could see which would help us diagnose what’s going on here:

  1. the log you get when running yarn install or npm install. Are there any errors? Do you have --ignore-scripts=true in any config or on the CLI? Just the log from RUN yarn install would be sufficient; and shouldn’t contain any proprietary information.
  2. the tree structure as is actually laid out on disk. You could get it by running tree /usr/src/directory/node_modules/elm.

I see this issue too when using yarn inside docker. Many times when installing packages yarn will try to rebuild the elm binary, and you can end up with a corrupted one.

Forcing yarn to rebuild elm works for me. Try yarn --force.

I wouldn’t bother installing Elm via node inside docker, just grab the binary itself :slight_smile:

FROM alpine
RUN apk add binutils && wget -qO - "https://github.com/elm/compiler/releases/download/0.19.0/binaries-for-linux.tar.gz" | tar -zxC /usr/local/bin/ && strip /usr/local/bin/elm && apk del binutils

Edit: kudos to @dmy for coming up with the minification, the resulting image is actually smaller than the original linux elm binary :sunny:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.