Flow-bin exiting with ENOENT in alpine docker container #3649

Closed
mightyguava opened this Issue Apr 3, 2017 · 15 comments

Comments

Projects
None yet
10 participants
@mightyguava

mightyguava commented Apr 3, 2017

I have flow working just fine in a project running locally on a Mac, but trying to run this on the official Node alpine base image is not working. Error and minimal repro steps pasted below.

I think #1605 fixes compilation of flow in a docker container, and I'm able to build a working flow binary following instructions there, but it'd be nice if the yarn installed flow could either "just work", or only requiring installing some os-dependencies, versus building flow from scratch.

Error with yarn installed flow

# Start a container
docker run -ti --rm node:7.8.0-alpine sh
# Now in container
mkdir test
cd test
yarn init
yarn add flow flow-bin --dev
yarn run flow

Errors:

yarn run v0.21.3
$ "/test/node_modules/.bin/flow"
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: spawn /test/node_modules/flow-bin/flow-linux64-v0.42.0/flow ENOENT
    at exports._errnoException (util.js:1034:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:423:7)
    at startup (bootstrap_node.js:147:9)
    at bootstrap_node.js:538:3
error Command failed with exit code 1.

workaround (partial): To build flow in alpine node, in case this is useful to anyone

FROM node:7.7.2-alpine
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
  && apk --no-cache add \
     alpine-sdk \
     ocaml \
     ocamlbuild \
     libelf \
     libelf-dev \
     ncurses \
     inotify-tools \
     linux-headers \
     git \
     bash \
     diffutils \
  && git clone --depth 1 https://github.com/facebook/flow.git /tmp/flow \
  && cd /tmp/flow \
  && make \
  && cp bin/flow /usr/bin/flow \
  && apk --no-cache del \
     alpine-sdk \
     ocaml \
     ocamlbuild \
     libelf-dev \
     ncurses \
     inotify-tools \
     linux-headers \
     git \
     bash \
     diffutils \
  && cd / \
  && rm -rf /tmp/flow
@montogeek

This comment has been minimized.

Show comment
Hide comment
@montogeek

montogeek Apr 3, 2017

Contributor

Funny, I am trying to do the same, the problem is that this dep is missing:
Error loading shared library libelf.so.1,
I am unable to install it

Contributor

montogeek commented Apr 3, 2017

Funny, I am trying to do the same, the problem is that this dep is missing:
Error loading shared library libelf.so.1,
I am unable to install it

@mightyguava

This comment has been minimized.

Show comment
Hide comment
@mightyguava

mightyguava Apr 3, 2017

@montogeek did that come from the apk add libelf? I had libelf installed and the flow binary from npm still didn't work for me

@montogeek did that come from the apk add libelf? I had libelf installed and the flow binary from npm still didn't work for me

@montogeek

This comment has been minimized.

Show comment
Hide comment
@montogeek

montogeek Apr 3, 2017

Contributor

@mightyguava I tried with ocaml, libelf, libelf-dev without luck, I gave up and switched to Debian: https://hub.docker.com/r/montogeek/docker-yarn-flow/

Contributor

montogeek commented Apr 3, 2017

@mightyguava I tried with ocaml, libelf, libelf-dev without luck, I gave up and switched to Debian: https://hub.docker.com/r/montogeek/docker-yarn-flow/

@izumin5210

This comment has been minimized.

Show comment
Hide comment
@izumin5210

izumin5210 Apr 5, 2017

elfutils-libelf seems to contain libelf.so.1. https://pkgs.alpinelinux.org/contents?file=&path=&name=elfutils-libelf&branch=edzge&repo=main&arch=x86_64
I tried with elfutils-dev, elfutils-dev, libelf but still didn't work...

elfutils-libelf seems to contain libelf.so.1. https://pkgs.alpinelinux.org/contents?file=&path=&name=elfutils-libelf&branch=edzge&repo=main&arch=x86_64
I tried with elfutils-dev, elfutils-dev, libelf but still didn't work...

@montogeek

This comment has been minimized.

Show comment
Hide comment
@montogeek

montogeek Apr 5, 2017

Contributor

@izumin5210 So, Flow is running after installing elfutils-libelf?

Contributor

montogeek commented Apr 5, 2017

@izumin5210 So, Flow is running after installing elfutils-libelf?

@vkurchatkin

This comment has been minimized.

Show comment
Hide comment
@vkurchatkin

vkurchatkin Apr 5, 2017

Collaborator

libc might be the culprit, binaries compiled against glibc don't work on alpine

Collaborator

vkurchatkin commented Apr 5, 2017

libc might be the culprit, binaries compiled against glibc don't work on alpine

@xdissent

This comment has been minimized.

Show comment
Hide comment
@xdissent

xdissent Apr 13, 2017

It's definitely glibc. I tried the alpine glibc-compat stuff too but ultimately gave up. For building, the correct packages are elfutils-* not libelf-*:

FROM node:alpine

ENV FLOW_VERSION 0.43.1

RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
  && apk add --no-cache --virtual .build-deps-flow \
     alpine-sdk \
     bash \
     diffutils \
     elfutils-dev \
     git \
     linux-headers \
     ncurses \
     ocaml \
     ocamlbuild \
  && git clone --depth 1 --branch "v$FLOW_VERSION" https://github.com/facebook/flow.git \
  && cd flow \
  && make test \
  && cp bin/flow /usr/bin/flow \
  && apk del .build-deps-flow \
  && apk add --no-cache elfutils-libelf \
  && cd .. \
  && rm -rf flow

Change make test to make if you don't care about tests. Random note: the tests fail if you build in /tmp/flow because it writes some test fixtures under that folder, and they accidentally find flow's own .flowconfig when they shouldn't.

It's definitely glibc. I tried the alpine glibc-compat stuff too but ultimately gave up. For building, the correct packages are elfutils-* not libelf-*:

FROM node:alpine

ENV FLOW_VERSION 0.43.1

RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
  && apk add --no-cache --virtual .build-deps-flow \
     alpine-sdk \
     bash \
     diffutils \
     elfutils-dev \
     git \
     linux-headers \
     ncurses \
     ocaml \
     ocamlbuild \
  && git clone --depth 1 --branch "v$FLOW_VERSION" https://github.com/facebook/flow.git \
  && cd flow \
  && make test \
  && cp bin/flow /usr/bin/flow \
  && apk del .build-deps-flow \
  && apk add --no-cache elfutils-libelf \
  && cd .. \
  && rm -rf flow

Change make test to make if you don't care about tests. Random note: the tests fail if you build in /tmp/flow because it writes some test fixtures under that folder, and they accidentally find flow's own .flowconfig when they shouldn't.

@amacleay amacleay referenced this issue in flowtype/flow-bin May 2, 2017

Closed

Unable to launch binary in docker image #72

@Vrtak-CZ

This comment has been minimized.

Show comment
Hide comment
@Vrtak-CZ

Vrtak-CZ May 3, 2017

I'm just trying docker file posted by @xdissent with 0.45.0 and after I added ocaml-findlib to build-deps it fails with error:

ocamlfind ocamldep -package sedlex -modules src/flow.ml > src/flow.ml.depends
+ ocamlfind ocamldep -package sedlex -modules src/flow.ml > src/flow.ml.depends
ocamlfind: Package `sedlex' not found

😢

Vrtak-CZ commented May 3, 2017

I'm just trying docker file posted by @xdissent with 0.45.0 and after I added ocaml-findlib to build-deps it fails with error:

ocamlfind ocamldep -package sedlex -modules src/flow.ml > src/flow.ml.depends
+ ocamlfind ocamldep -package sedlex -modules src/flow.ml > src/flow.ml.depends
ocamlfind: Package `sedlex' not found

😢

@xdissent

This comment has been minimized.

Show comment
Hide comment
@xdissent

xdissent May 3, 2017

Here's an updated Dockerfile for 0.45.0. I'm unfamiliar with opam but I think adding a rm -rf ~/.opam might clean up some files that aren't needed after compilation.

FROM node:alpine

ENV FLOW_VERSION 0.45.0

RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
  && apk add --no-cache --virtual .build-deps-flow \
     alpine-sdk \
     bash \
     diffutils \
     elfutils-dev \
     git \
     linux-headers \
     m4 \
     ncurses \
     ocaml \
     opam \
  && opam init -y \
  && eval `opam config env` \
  && opam update \
  && opam install -y ocamlfind sedlex \
  && git clone --depth 1 --branch "v$FLOW_VERSION" https://github.com/facebook/flow.git \
  && cd flow \
  && yarn \
  && make test \
  && cp bin/flow /usr/bin/flow \
  && apk del .build-deps-flow \
  && apk add --no-cache elfutils-libelf \
  && cd .. \
  && rm -rf flow

xdissent commented May 3, 2017

Here's an updated Dockerfile for 0.45.0. I'm unfamiliar with opam but I think adding a rm -rf ~/.opam might clean up some files that aren't needed after compilation.

FROM node:alpine

ENV FLOW_VERSION 0.45.0

RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
  && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
  && apk add --no-cache --virtual .build-deps-flow \
     alpine-sdk \
     bash \
     diffutils \
     elfutils-dev \
     git \
     linux-headers \
     m4 \
     ncurses \
     ocaml \
     opam \
  && opam init -y \
  && eval `opam config env` \
  && opam update \
  && opam install -y ocamlfind sedlex \
  && git clone --depth 1 --branch "v$FLOW_VERSION" https://github.com/facebook/flow.git \
  && cd flow \
  && yarn \
  && make test \
  && cp bin/flow /usr/bin/flow \
  && apk del .build-deps-flow \
  && apk add --no-cache elfutils-libelf \
  && cd .. \
  && rm -rf flow
@Vrtak-CZ

This comment has been minimized.

Show comment
Hide comment

@xdissent xdissent referenced this issue in flowtype/flow-bin Jun 8, 2017

Closed

Missing libelf.so.1 #58

@xdissent

This comment has been minimized.

Show comment
Hide comment
@xdissent

xdissent Jun 13, 2017

Now that v0.48.0 doesn't need libelf, flow works with alpine-pkg-glibc (no compilation required).

Install flow normally (binary release or flow-bin) and run:

$ wget -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
$ wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk
$ apk add glibc-2.25-r0.apk

Now that v0.48.0 doesn't need libelf, flow works with alpine-pkg-glibc (no compilation required).

Install flow normally (binary release or flow-bin) and run:

$ wget -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
$ wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk
$ apk add glibc-2.25-r0.apk
@xjunior

This comment has been minimized.

Show comment
Hide comment
@xjunior

xjunior Nov 25, 2017

I'm still having that issue running in a node:8.9-alpine container. Is alpine-pkg-glibc still required?

xjunior commented Nov 25, 2017

I'm still having that issue running in a node:8.9-alpine container. Is alpine-pkg-glibc still required?

@juanpicado

This comment has been minimized.

Show comment
Hide comment
@juanpicado

juanpicado Dec 2, 2017

Yes, it works with node:8.9.0-alpine. But I'd adjust the @xdissent to the readme in this repo, his example fails, but the one at the page works fine. https://github.com/sgerrand/alpine-pkg-glibc

I'm using flow@0.60.0

Here my example https://github.com/verdaccio/verdaccio/blob/feature-jest-test/Dockerfile

juanpicado commented Dec 2, 2017

Yes, it works with node:8.9.0-alpine. But I'd adjust the @xdissent to the readme in this repo, his example fails, but the one at the page works fine. https://github.com/sgerrand/alpine-pkg-glibc

I'm using flow@0.60.0

Here my example https://github.com/verdaccio/verdaccio/blob/feature-jest-test/Dockerfile

@FezVrasta

This comment has been minimized.

Show comment
Hide comment
@FezVrasta

FezVrasta Mar 29, 2018

"Yes" means, "Yes, it's still required". For anyone wondering it.

"Yes" means, "Yes, it's still required". For anyone wondering it.

@jirutka

This comment has been minimized.

Show comment
Hide comment
@jirutka

jirutka Jul 7, 2018

I've created Alpine package for Flow. It's available for x86_64 and aarch64 in the Alpine's testing repository for now. No glibc hacks are needed. Just install it using apk, e.g.:

apk add --repository https://nl.alpinelinux.org/alpine/edge/testing flow

jirutka commented Jul 7, 2018

I've created Alpine package for Flow. It's available for x86_64 and aarch64 in the Alpine's testing repository for now. No glibc hacks are needed. Just install it using apk, e.g.:

apk add --repository https://nl.alpinelinux.org/alpine/edge/testing flow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment