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

Build flow for alpine from scratch #68

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
sudo: false
sudo: true
services:
- docker
language: node_js
node_js:
- 'stable'
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FLOW_VERSION ?= $(shell node -p 'require("./package.json").version')
FLOW_BINS = \
flow-linux64-v$(FLOW_VERSION)/flow \
flow-linux64-musl-v$(FLOW_VERSION)/flow \
flow-osx-v$(FLOW_VERSION)/flow \
flow-win64-v$(FLOW_VERSION)/flow.exe

Expand Down Expand Up @@ -32,6 +33,12 @@ get-flow = \
flow-linux64-v%/flow:
$(get-flow)

flow-linux64-musl-v%/flow:
mkdir -p $(@D) && \
cd flow-linux64-musl-build && \
docker build --build-arg FLOW_TAG=v$(*F) -t flow-musl-build . && \
docker run -v $(PWD)/$(@D):/out --rm -ti flow-musl-build cp /tmp/flow/bin/flow /out/ \

flow-osx-v%/flow:
$(get-flow)

Expand Down
1 change: 1 addition & 0 deletions SHASUM256.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ca40e98614074a5358f17733b2b06885977bb6a03f55e3488e366d5dd0861497 flow-linux64-v0.43.0/flow
73a717da991b24ff12fa1809f31286d49ee35a0a16489d16acde403125ae1e9d flow-linux64-musl-v0.43.0/flow
deb3b619c60abb16676679c2c4df265bc0f42278a631ab88a1777f10a6779475 flow-osx-v0.43.0/flow
9ab57b8c731454d23e337255aa675da6333e46ca59c035f78c732ab9039d5361 flow-win64-v0.43.0/flow.exe
24 changes: 24 additions & 0 deletions flow-linux64-musl-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:6.9.4-alpine

ARG FLOW_TAG

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

RUN npm install -g yarn
RUN git clone --depth 1 https://github.com/facebook/flow.git /tmp/flow \
&& cd /tmp/flow \
&& yarn
RUN cd /tmp/flow && make
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,30 @@
var VERSION = require('./package.json').version;

var path = require('path');
var fs = require('fs');

function isLibcMusl() {
try {
var contents = fs.readFileSync(process.execPath);

// Buffer.indexOf was added in v1.5.0 so cast to string for old node
// Delay contents.toStrings because it's expensive
if (!contents.indexOf) {
contents = contents.toString();
}

if (contents.indexOf('libc.musl-x86_64.so.1') !== -1) {
return true;
}
} catch (err) { } // eslint-disable-line no-empty
return false;
}

module.exports =
process.platform === 'darwin'
? path.join(__dirname, 'flow-osx-v' + VERSION, 'flow') :
process.platform === 'linux' && isLibcMusl() && process.arch === 'x64'
? path.join(__dirname, 'flow-linux64-musl-v' + VERSION, 'flow') :
process.platform === 'linux' && process.arch === 'x64'
? path.join(__dirname, 'flow-linux64-v' + VERSION, 'flow') :
process.platform === 'win32' && process.arch === 'x64'
Expand Down