mhart / alpine-node Goto Github PK
View Code? Open in Web Editor NEWMinimal Node.js Docker Images built on Alpine Linux
License: MIT License
Minimal Node.js Docker Images built on Alpine Linux
License: MIT License
Node is unable to connect to a MongoDB instance hosted outside the image.
NPM package mongoose
is being used to connect to the database. Given the IP address and port (unchanged) of the MongoDB, the code works just fine without making a change if we use node:latest
image from Dockerhub.
Could this be because outbound communication is blocked?
My node process does not exit (aborted) when it is out of memory. Instead it just prints
<--- Last few GCs --->
1095 ms: Mark-sweep 27.4 (62.7) -> 21.2 (59.4) MB, 33.0 / 0 ms (+ 5.5 ms in 42 steps since start of marking, biggest step 0.4 ms) [allocation failure] [GC in old space requested].
1114 ms: Mark-sweep 21.2 (59.4) -> 21.2 (59.4) MB, 19.1 / 0 ms [allocation failure] [GC in old space requested].
1132 ms: Mark-sweep 21.2 (59.4) -> 20.9 (59.4) MB, 17.6 / 0 ms [last resort gc].
1149 ms: Mark-sweep 20.9 (59.4) -> 20.9 (59.4) MB, 17.5 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1767b25c9e59 <JS Object>
2: _repeat [/usr/src/app/memory.js:~10] [pc=0x54102d5f9b1] (this=0x3cc32928c999 <a Timeout with map 0x34877b623bb1>)
3: _onTimeout(aka wrapper) [timers.js:417] [pc=0x54102d5d7b3] (this=0x3cc32928c999 <a Timeout with map 0x34877b623bb1>)
4: tryOnTimeout(aka tryOnTimeout) [timers.js:224] [pc=0x54102d5d4e3] (this=0x1767b2504189 <undefined>,timer=0x3cc32928c999 <a Timeout with map 0x348...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
and then starts using 100% CPU.
This is a serious safety issue. Is this expected due to difference with glibc and musl?
When I try it with node:argon container exits as expected after printing the same information as above.
To mimic the behaviour, I have created a Dockerfile and a js file that leaks memory:
memory.zip
Native modules that use dynamic linking cannot be used. This may be related to the --fully-static
arg used during compiling.
npm install bcrypt
require('bcrypt');
Module is required and available to use.
Error is thrown:
/app/node_modules/bindings/bindings.js:83
throw e
^
Error: Dynamic loading not supported
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at bindings (/app/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:3:35)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/app/models/user.js:6:37)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
Hi, according to the docs (and in consistency with 6.3.0) it should contain npm
, but:
~$ docker run -ti --rm mhart/alpine-node-auto:6.3.1 sh
/ # npm
sh: npm: not found
/ # find . -name npm
/ #
Can you please rebuild?
$ docker exec -it node-app-1 /bin/bash
exec: "bash": executable file not found in $PATH
Is there another way one can get in the running alpine-node based container?
Why build your dockerfile , very large image.
Hi,
thanks for the great alpine based node image. Would you mind to use docker automated builds for your images to make the integrity verifiable? That would be really nice. If you don't want to, I would fork the project and do it on my own. I just wanted to let you know and choose your way to do it.
Hi, I was trying to rebuild the image, but getting the following error:
g++ -pthread -rdynamic -m64 -o /node-v5.10.1/out/Release/openssl-cli -Wl,--start-group /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/app_rand.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/apps.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/asn1pars.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ca.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ciphers.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/cms.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/crl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/crl2p7.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dgst.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dh.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dhparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dsaparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ec.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ecparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/enc.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/engine.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/errstr.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/gendh.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/gendsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/genpkey.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/genrsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/nseq.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ocsp.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/openssl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/passwd.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkcs12.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkcs7.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkcs8.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkey.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkeyparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkeyutl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/prime.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/rand.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/req.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/rsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/rsautl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_cb.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_client.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_server.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_socket.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_time.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/sess_id.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/smime.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/speed.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/spkac.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/srp.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ts.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/verify.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/version.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/x509.o /node-v5.10.1/out/Release/obj.target/deps/openssl/libopenssl.a -Wl,--end-group -static -ldl
g++ -pthread -rdynamic -m64 -fuse-ld=gold -B/node-v5.10.1/third_party/binutils/Linux_x64/Release/bin -m64 -o /node-v5.10.1/out/Release/mksnapshot -Wl,--start-group /node-v5.10.1/out/Release/obj.target/mksnapshot/deps/v8/src/snapshot/mksnapshot.o /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_nosnapshot.a /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_libplatform.a /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_libbase.a -Wl,--end-group -static -ldl -lrt
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: /node-v5.10.1/out/Release/mksnapshot: Not supported
collect2: error: ld returned 1 exit status
make[1]: *** [/node-v5.10.1/out/Release/mksnapshot] Error 1
deps/v8/tools/gyp/mksnapshot.target.mk:140: recipe for target '/node-v5.10.1/out/Release/mksnapshot' failed
make[1]: Leaving directory '/node-v5.10.1/out'
make: *** [node] Error 2
Makefile:63: recipe for target 'node' failed
The command '/bin/sh -c apk add --no-cache curl make gcc g++ binutils-gold python linux-headers paxctl libgcc libstdc++ gnupg && gpg --keyserver pool.sks-keyservers.net --recv-keys 9554F04D7259F04124DE6B476D5A82AC7E37093B && gpg --keyserver pool.sks-keyservers.net --recv-keys 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 && gpg --keyserver pool.sks-keyservers.net --recv-keys 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 && gpg --keyserver pool.sks-keyservers.net --recv-keys FD3A5288F042B6850C66B31F09FE44734EB7990E && gpg --keyserver pool.sks-keyservers.net --recv-keys 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 && gpg --keyserver pool.sks-keyservers.net --recv-keys DD8F2338BAE7501E3DD5AC78C273792F7D83545D && gpg --keyserver pool.sks-keyservers.net --recv-keys C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 && gpg --keyserver pool.sks-keyservers.net --recv-keys B9AE9905FFD7803F25714661B63B535A4C206CA9 && curl -o node-${VERSION}.tar.gz -sSL https://nodejs.org/dist/${VERSION}/node-${VERSION}.tar.gz && curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc && gpg --verify SHASUMS256.txt.asc && grep node-${VERSION}.tar.gz SHASUMS256.txt.asc | sha256sum -c - && tar -zxf node-${VERSION}.tar.gz && cd /node-${VERSION} && ./configure --prefix=/usr ${CONFIG_FLAGS} && make -j$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && make install && paxctl -cm /usr/bin/node && cd / && if [ -x /usr/bin/npm ]; then npm install -g npm@${NPM_VERSION} && find /usr/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf; fi && apk del curl make gcc g++ binutils-gold python linux-headers paxctl gnupg ${DEL_PKGS} && rm -rf /etc/ssl /node-${VERSION}.tar.gz /SHASUMS256.txt.asc /node-${VERSION} ${RM_DIRS} /usr/share/man /tmp/* /var/cache/apk/* /root/.npm /root/.node-gyp /root/.gnupg /usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/html' returned a non-zero code: 2`
Current image has broken openssl. It would be nice to have it rebuilt with the updated/fixed alpine images ASAP.
(They should also have a significantly faster default mirror)
So I ran into this issue npm/npm#11699 in version 5.8 and 5.9 of the container as node is still packaging npm 3.8.0 and this was fixed in 3.8.1.
Obviously I when I tried to update npm I ran into npm/npm#9863
However when I tried the solution there I could not install fs-extra into the npm directory due to
npm/npm#10686
So I finally came up with this line in my Dockerfile to update npm thought you might be interested in integrating it in to this container
npm install fs-extra \
&& cp -r node_modules/* /usr/lib/node_modules/npm/node_modules \
&& sed -i s/graceful-fs/fs-extra/g /usr/lib/node_modules/npm/lib/utils/rename.js \
&& sed -i s/fs.rename/fs.move/g /usr/lib/node_modules/npm/lib/utils/rename.js \
&& rm -rf node_modules \
&& npm install -g npm@latest
Docker Cloud uses DNS rather than modifications to /etc/hosts to enable lookup between linked containers. Unfortunately, it triggers the same errors with musl that occur with Kubernetes (I think).
I realize this is an upstream problem; I figured I'd add an issue here so people would know where to find it. It might be worthwhile to mention in the README, like the Kubernetes issue.
Example file attached. Supposedly "alpine:edge" works correctly, so I'm going to see if I can build alpine-node with the edge tag instead of 3.3.
Hi!
I have just encountered this issue, since alpine linux was recently updated and you were so quick to update your image as well (great job, though! 👍 )
Some of the packages that I use in that image, are not present in alpine 3.4 so my build fails.
Is it possible to keep the "previous alpine" version up? So, in this case, it will be very useful to have a alpine-node:base
with Alpine 3.3 and another with Alpine 3.4.
Thanks!
I've updated iojs
package yesterday (pull-requested and it is already in testing
repo) and nodejs
package can be updated as well. However, I'm not in nodejs/iojs development, I just wanted to play with it, so I won't be able to maintain those packages.
Wouldn't you volunteer to maintain iojs and, possibly, nodejs packages?
Upgrading to node 6.3.0 and I'm oddly not able to build native modules anymore. I am able to compile them fine locally (I'm using nvm) so I'm not sure if it's docker or node or npm or whatever, but this seems like the most appropriate place to start!
I've got an example for you at https://github.com/toddself/alpine-node-test
This works like a charm: docker build -f Dockerfile-4 .
(FROM mhart/alpine-node:4
)
This fails: docker build -f Dockerfile-6 .
(FROM mhart/alpine-node:6
)
Error is as follows:
> [email protected] install /node_modules/libpq
> node-gyp rebuild
module.js:442
throw err;
^
Error: Cannot find module 'nan'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at [eval]:1:1
at ContextifyScript.Script.runInThisContext (vm.js:25:33)
at Object.exports.runInThisContext (vm.js:77:17)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:541:32)
at bootstrap_node.js:315:29
gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Linux 4.4.0-28-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /node_modules/libpq
gyp ERR! node -v v6.3.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
[bunch of crap excised]
npm ERR! Linux 4.4.0-28-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v6.3.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the libpq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs libpq
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls libpq
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log
node-gyp will fail in a lot of cases if one doesn't use the npm bundled with iojs.
It would be great to be able to use your alpine-iojs package but without the npm update -g npm
part here: https://github.com/mhart/alpine-node/blob/master/Dockerfile.full#L21
I was getting an issue where a module would fail to build causing dependency hell. All that needed to be done is adding this one line:
RUN apk add --update python
I'll create a PR for this. I think it would be nice to have it included with this image since node-gyp is something used often within node.
gliderlabs is now official docker library — https://registry.hub.docker.com/_/alpine/ Please use official.
Hi, when I run npm install -g gulp
I get this, any clues?
---> Running in dea67c4677aa
npm ERR! Linux 4.1.18-boot2docker
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "gulp"
npm ERR! node v5.7.1
npm ERR! npm v3.7.5
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! syscall getaddrinfo
npm ERR! getaddrinfo EAI_AGAIN registry.npmjs.org:80
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /root/app/npm-debug.log
I thought it was a SSL issue, so I tried running npm config set strict-ssl false && npm config set registry http://registry.npmjs.org
, and I'm getting the same error.
Latest alpine linux image is 3.3. They are pretty the same but in 3.3 new community repo was introduced. It is very helpful in custom builds.
It would be great to have latest base image for nodejs apps.
Installing kerberos module and get below error, which can be solved by installing libkrb5-dev (Debian/Ubuntu) or krb5-devel (CentOS) , accrording https://github.com/christkv/kerberos/issues/21.
Is there a package available in alpine ?
> [email protected] install /home/src/reedsec-risk-gateway/node_modules/kerberos
> (node-gyp rebuild) || (exit 0)
make: Entering directory '/home/src/reedsec-risk-gateway/node_modules/kerberos/build'
CXX(target) Release/obj.target/kerberos/lib/kerberos.o
In file included from ../lib/kerberos.cc:1:0:
../lib/kerberos.h:5:27: fatal error: gssapi/gssapi.h: No such file or directory
compilation terminated.
kerberos.target.mk:100: recipe for target 'Release/obj.target/kerberos/lib/kerberos.o' failed
make: *** [Release/obj.target/kerberos/lib/kerberos.o] Error 1
make: Leaving directory '/home/src/reedsec-risk-gateway/node_modules/kerberos/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.4.12-boot2docker
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/src/reedsec-risk-gateway/node_modules/kerberos
gyp ERR! node -v v4.4.7
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
Hi Michael, not sure if I'm missing something but when I try and build the image using your Dockerfile I get the following error:
/usr/lib/gcc/x86_64-alpine-linux-musl/4.9.2/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: /node-v4.2.4/out/Release/mksnapshot: Not supported
collect2: error: ld returned 1 exit status
deps/v8/tools/gyp/mksnapshot.target.mk:139: recipe for target '/node-v4.2.4/out/Release/mksnapshot' failed
make[1]: Leaving directory '/node-v4.2.4/out'
make[1]: *** [/node-v4.2.4/out/Release/mksnapshot] Error 1
Makefile:45: recipe for target 'node' failed
make: *** [node] Error 2
Building on an Ubuntu 14.04 VM.
Any ideas?
when uncommenting this line:
ENV VERSION=v0.10.46 CFLAGS="-D__USE_MISC" NPM_VERSION=2
running docker build results with this error:
node-v0.10.46.tar.gz: OK
Usage: configure [options]
configure: error: no such option: --fully-static
The command '/bin/sh -c apk add --no-cache curl make gcc g++ python linux-headers paxctl libgcc libstdc++ gnupg && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 9554F04D7259F04124DE6B476D5A82AC7E37093B 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 FD3A5288F042B6850C66B31F09FE44734EB7990E 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 DD8F2338BAE7501E3DD5AC78C273792F7D83545D C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 B9AE9905FFD7803F25714661B63B535A4C206CA9 && curl -o node-${VERSION}.tar.gz -sSL https://nodejs.org/dist/${VERSION}/node-${VERSION}.tar.gz && curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc && gpg --verify SHASUMS256.txt.asc && grep node-${VERSION}.tar.gz SHASUMS256.txt.asc | sha256sum -c - && tar -zxf node-${VERSION}.tar.gz && cd node-${VERSION} && export GYP_DEFINES="linux_use_gold_flags=0" && ./configure --prefix=/usr
Now that Node.js has an LTS version, might it be a good idea to also have an lts
tag here?
Hello!
I have an issue with the container, when I try to build it myself (I want to test it against alpine:edge).
I'm taking the current Dockerfile provided on this repo and do a docker build -t mytag .
. But then my image size is 398.6 MB. Do you have any clue about this? Anything special to do?
Thanks
Edit: after investigation, folder /usr/lib/node_modules/npm/.nyc_output
takes up to 330 MB. I added it to the final rm command. If usefull, I'm building on OSX using latest Docker for mac beta
Wondering what the purpose of the paxctl -cm
line is in the installation.
Can you please kick your docker repository, so we get the newest 6.3.1 build?
(https://hub.docker.com/r/mhart/alpine-node-auto/)
Thanks :)
any reason not to use the official package?
https://pkgs.alpinelinux.org/packages?name=nodejs&branch=v3.3&repo=&arch=x86_64&maintainer=
Heya!
It would be great to have the edge base alpine tag to chose from this repo tags so we can get the latest Alpine (we need some fixes from 3.4 here, not yet published but in edge)
this would possibly be also useful
When running image, I get error:
$ docker run -it mhart/alpine-node:4 sh
standard_init_linux.go:175: exec user process caused "exec format error"
This is on my Raspberry Pi.
$ docker info
Containers: 12
Running: 0
Paused: 0
Stopped: 12
Images: 21
Server Version: 1.12.1
Storage Driver: overlay
Backing Filesystem: extfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options:
Kernel Version: 4.4.15-hypriotos-v7+
Operating System: Raspbian GNU/Linux 8 (jessie)
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 862 MiB
Name: black-pearl
ID: QLG7:HLFA:YNZ2:SNNF:5XC3:ORPG:WUM6:NC3K:JK45:RXPO:SGCL:NI6J
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No cpuset support
Insecure Registries:
127.0.0.0/8
I use FROM mhart/alpine-node
in my dockerfile and I added build-base make gcc g++ python
with apk add
because I need the node-serialport npm package https://github.com/voodootikigod/node-serialport which has to compile some binaries.
> [email protected] install /app/node_modules/serialport
> node-pre-gyp install --fallback-to-build
[serialport] Success: "/app/node_modules/serialport/build/Release/node-v46-linux-x64/serialport.node" is installed via remote
[email protected] node_modules/serialport
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
└── [email protected] ([email protected], [email protected])
However as soon as I try to user node-serialport it fails with:
npm ERR! Linux 3.19.0-30-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v4.3.0
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /app/app/npm-debug.log
module.js:435
return process.dlopen(module, path._makeLong(filename));
^
Error: Error relocating /app/app/node_modules/serialport/build/Release/node-v46-linux-x64/serialport.node: __strcpy_chk: symbol not found
at Error (native)
at Object.Module._extensions..node (module.js:435:18)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/app/app/node_modules/serialport/serialport.js:14:25)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
I already opened an issue serialport/node-serialport#682 however it is not getting very much attention. I believe this is an issue with alpine because on ubuntu it used to work fine. Here is some installation information:
We are using node-pre-gyp to compile and post binaries of the library for most common use cases (linux, mac, windows on standard processor platforms). If you are on a special case, node-serialport will work, but it will compile the binary when you install.
This assumes you have everything on your system necessary to compile ANY native module for Node.js. This may not be the case, though, so please ensure the following are true for your system before filing an issue about "Does not install". For all operatings systems, please ensure you have Python 2.x installed AND not 3.0, node-gyp (what we use to compile) requires Python 2.x.
Do you have an idea how to solve this?
using net-keepalive module that used node-ffi https://www.npmjs.com/package/net-keepalive
throws this error:
Dynamic Symbol Retrieval Error: Symbol not found: errno
judging from the quick google search it seems that is something regarding libc
some solutions involve setting correct path or maybe is something regarding musl?
Can this docker image be used in for example Google Container Engine, BlueMix or AWS?
I will try to avoid using Ubuntu or Debian. CoreOS is an option on GCE.
Hi
I took inspiration from your work to make my own alpine-nodejs +stuff Dockerfile. I got a puzzling issue : everything is building fine on my centos's VM but pushing to the public registry I end up with
collect2: error: ld returned 1 exit status �[0mdeps/v8/tools/gyp/mksnapshot.target.mk:139: recipe for target '/node-v5.6.0/out/Release/mksnapshot' failed �[91mmake[1]: *** [/node-v5.6.0/out/Release/mksnapshot] Error 1 �[0mmake[1]: Leaving directory '/node-v5.6.0/out' Makefile:45: recipe for target 'node' failed
Does that ring a bell to you by any chance?
Best regards,
I would like to know if you could consider to push this image to quay.io.
The reason is because is very good in terms of size and it'd very helpful to use it as a dependency for abuild (App Standard Container tool).
acbuild can use dependencies hosted under a domain (e.g example.com/nick/image), however as far as I know isn't possible to se docker images hosted in hub.docker.io as a dependency, but quay.io offer that making an APC image usable with rkt.
An example of an quay.io image can be used in acbuild is https://github.com/appc/acbuild/blob/master/examples/nodejs/build-nodejs.sh#L19
I think that this is the best solution than others as forking this repo only for that purpose; there's actually a fork for that but is out of date and I think that for you only would be to setup a free account in quay.io and register the hook.
Thanks for considering.
see this mysqljs/mysql#1236
I get the following error when running Docker on Ubuntu 15.04:
OK: 177 MiB in 52 packages
Executing busybox-1.23.2-r0.trigger
Executing ca-certificates-20141019-r2.trigger
tar: invalid magic
tar: short read
INFO[0028] The command [/bin/sh -c apk add --update curl make gcc g++ python linux-headers paxctl libgcc libstdc++ && curl -sSL https://nodejs.org/dist/${VERSION}/node-${VERSION}.tar.gz | tar -xz && cd /node-${VERSION} && ./configure --prefix=/usr
Building node-gyp has come up a few times in the issues, and I understand that including the tools to build it adds significantly to the image size, making it larger than even the slim
images from the official node builds.
However the current readme example installs the dev tools to an intermediate layer, which makes it impossible to clean up and keep the image size low without using an external squash program.
If you want to clean up the dev tools after npm install
, you need to execute it all on a single RUN
command to prevent docker from creating bloated intermediate layers. There are two options, a one line script chained together with &&
or including a ash build script in your repo then calling that with RUN
.
The first option is likely sufficient. For example:
RUN apk add --no-cache make gcc g++ python && \
npm install && \
npm cache clean && \
apk del make gcc g++ python
Including this in the readme might help some of those looking to use this image (thanks btw, love it!) but still need to build node-gyp.
First of all, thanks for creating and maintaining such a wonderful docker image! You're always so quick to update when a new version of node comes out 💯. And now for my question...
In the official docker-node repo, there is a Best Practices doc that explains you should create a user instead of running as root.
# Add our user and group first to make sure their IDs get assigned consistently
RUN groupadd -r app && useradd -r -g app app
Does alpine-node have a similar best practice?
What is the equivalent groupadd
and useradd
in Alpine?
node-gyp, which is often used by packages installed through npm (at least that is my experience), needs python
, make
, and gcc
. Would it make sense not to clean those up? (Currently happening in line 36 of the Dockerfile)
Hi,
Running into this weird error on ubuntu 14.04 with docker installed properly via docker.io's method.
Any ideas?
$ sudo docker run -it mhart/alpine-node:latest /bin/sh
no such file or directory
Error response from daemon: Cannot start container 1644f323eeb4695d64919ec564ee14484ed58e1573ece583226de4dccfdebdc3: [8] System error: no such file or directory
FYI, this works fine on my local docker instance on OS X... so I am kind of confused here as of what is missing.
Thank you!
npm packages pointing to Github repos are not installed because it can't find the git
binary.
Hi,
I tried to get this dockerfile crosscompiled on ARM as well, but got errors.
This seems to fix it:
It seems nodejs needs --without-snapshot and vfvp3 as a minimum, otherwise it crashes on ARM
Not sure if and how we should merge this.
In any case, people who want it can grab the dockerfile here:
https://github.com/coderofsalvation/alpine-node-arm
or the precompiled tarball here:
https://github.com/coderofsalvation/alpine-node-arm/raw/master/node-v4.1.1-armhf-alpinelinux.tar.gz
Compare with official node images, I can't find any mhart/alpine-node with tag of onbuild
, which is useful.
For example,
FROM mhart/alpine-node:4
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ONBUILD COPY package.json /usr/src/app/
ONBUILD RUN npm install
ONBUILD COPY . /usr/src/app
CMD [ "npm", "start" ]
Could you plan the onbuild image as above for all version?
Hi
I started a repository on quay.io quay.io/loicmahieu/alpine-node
for testing git tag
to docker tag
and it works pretty well so I thought that it can be useful to share the idea here.
So the idea behind image quay.io/loicmahieu/alpine-node
is:
base-v3.3.0
v3.3.0
base-v4.0.0
v4.0.0
Tags without base-
are full build.
(heads/master)|(tags/(base-)?v([0-9]+)\.([0-9]+)\.([0-9]+))
At this time, the image quay.io/loicmahieu/alpine-node
is build from my fork. The only difference between my fork and @mhart is the git tags. I written a small script for automatically create tags from commit message: https://gist.github.com/LoicMahieu/db7e5f4916714d97fb67
Caveat of Quay.io:
git push origin [tag]
one tag at the time.My idea behind this issue is only to open the discussion.
Thanks!
Could be the case that I missed something but the Readme says that alpine-node-base
has a 0.12.7 tag but it has not.
What I noticed tho is that latest
seems to give you 0.12.7
. Did the missing tag happen by mistake or by intend?
While trying to package a NodeJS application I get the following stack trace:
> node ./bin/www
module.js:440
throw err;
^
Error: Cannot find module 'debug'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/bin/www:2:13)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
npm ERR! Linux 4.3.6-coreos
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v6.1.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the IoT-Playground package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs IoT-Playground
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls IoT-Playground
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log
Not sure why this is happening. I even tried building my own node image by compiling everything from source (like you did), and the same thing happened.
Any idea what might be causing this?
Just a quick question.
Why is the alpine 3.4 base image only used for the node 6.2.1 build, and not for the 5.x, 4.x, 0.12, and 0.10 versions?
I can see it is deliberately moved back to 3.3 for those versions, so I'm guessing there is a good reason.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.