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

Add musl build based on alpine linux image #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ install:
- >- # this should only run on linux
if [ $TRAVIS_OS_NAME = "linux" ]; then

docker build -t canvas-musl-prebuilt:latest -f docker/Dockerfile.musl .;
docker run
-e PREBUILD_VERSION="$PREBUILD_VERSION"
-e PREBUILD_AUTH="$PREBUILD_AUTH"
-e PREBUILD_SLUG="$TRAVIS_REPO_SLUG"
-e PREBUILD_NODE_VERSIONS="$PREBUILD_NODE_VERSIONS"
-v $(pwd):/build canvas-musl-prebuilt:latest
bash -c 'cd /build; export NVM_DIR=$HOME/.nvm; . $HOME/.nvm/nvm.sh; . ci/install.sh linux '"\"$PREBUILD_VERSION\" \"$PREBUILD_CANVAS_VERSION\" \"$PREBUILD_NODE_VERSIONS\"";

docker run
-e PREBUILD_VERSION="$PREBUILD_VERSION"
-e PREBUILD_AUTH="$PREBUILD_AUTH"
Expand Down
2 changes: 1 addition & 1 deletion ci/linux/bundle.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
copies=$(lddtree.sh -l node-canvas/build/Release/canvas.node | sed -r -e '/^\/lib/d' -e '/canvas.node$/d');
copies=$(lddtree -l node-canvas/build/Release/canvas.node | sed -r -e '/^\/lib/d' -e '/canvas.node$/d');

for so in $copies; do
cp $so node-canvas/build/Release
Expand Down
2 changes: 1 addition & 1 deletion ci/linux/node_version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VER=$1
source ~/.nvm/nvm.sh
source ~/.profile
nvm use $VER || { nvm install $VER; nvm use $VER; }
npm install -g node-gyp

46 changes: 46 additions & 0 deletions docker/Dockerfile.musl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM alpine:3.11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that Alpine 3.11 uses musl libc 1.1.24, released in October. Assuming musl adds symbols between releases, anyone with older versions won't be able to link against the binary. That's why the other Dockerfile uses an old Debian and compiles from source. So I think that might be one pre-req to merging this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I can make the change to an older version of alpine. How far back are you looking to go though?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chearon I was looking at this again and I think it makes sense to leave musl at 1.1.24. They are planning to EOL the 1.1 branch with the release of 1.2 in February but will be back-porting bug fixes down to 1.1.25 in the future. Also, all versions prior to 1.1.24 have security issues.

Similar to how musl will only be supported for node versions >= 12 (released in April 2019) I don't think it's unreasonable to only "officially" support musl >= 1.1.24 (released in Oct 2019). What do you think?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to jump in - given the EOL, eventual complications and that there are no better options either ways so far - having recent support now is better than having legacy support but too late.
Probably a lot of people in the K8S world are using Alpine as a base and are struggling / consuming power to build these for nothing :)

RUN apk update && apk add --no-cache \
build-base \
g++ \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev \
curl \
bash \
coreutils \
libstdc++ \
git \
librsvg-dev \
lddtree \
pax-utils \
zlib-dev \
libffi-dev \
libpng-dev \
libjpeg-turbo-dev \
fribidi-dev \
pcre-dev \
glib-dev \
freetype-dev \
harfbuzz-dev \
expat-dev \
fontconfig-dev \
pixman-dev \
python2 \
gdk-pixbuf-dev \
libxml2-dev \
libcroco-dev

RUN bash -c 'touch ~/.profile'

# https://stackoverflow.com/questions/52196518/could-not-get-uid-gid-when-building-node-docker
ENV npm_config_unsafe_perm=true
# Suppress g++ casting warnings that come from node, nan and v8 (https://github.com/nodejs/nan/issues/807)
ENV CXXFLAGS="-Wno-cast-function-type"
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash

# Get nvm to work with alpine https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
RUN bash -c 'echo "NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release" >> ~/.profile'
RUN bash -c 'echo "nvm_get_arch() { nvm_echo \"x64-musl\"; }" >> ~/.profile'

RUN bash -c 'source ~/.profile; cd; nvm install v12'