From 4ff53f462e70ef0ca29f0babf2c66b2ccf70eb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20HOUZ=C3=89?= Date: Thu, 25 Feb 2016 16:24:35 +0100 Subject: [PATCH 1/3] Add an Alpine variant. --- 4.3/alpine/Dockerfile | 66 +++++++++++++++++++++++++++++++++++ 5.7/alpine/Dockerfile | 66 +++++++++++++++++++++++++++++++++++ generate-stackbrew-library.sh | 2 +- test-build.sh | 2 +- update-npm.sh | 4 +-- update.sh | 4 +-- 6 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 4.3/alpine/Dockerfile create mode 100644 5.7/alpine/Dockerfile diff --git a/4.3/alpine/Dockerfile b/4.3/alpine/Dockerfile new file mode 100644 index 0000000000..5df1d8d50a --- /dev/null +++ b/4.3/alpine/Dockerfile @@ -0,0 +1,66 @@ +FROM alpine:latest + +ENV NPM_CONFIG_LOGLEVEL info +ENV NODE_VERSION=4.3.1 + +RUN apk --no-cache update \ + && apk --no-cache upgrade \ + && apk add --no-cache icu libintl libuv \ + && apk add --no-cache --virtual .build-deps \ + gcc \ + libgcc \ + g++ \ + libstdc++ \ + make \ + python \ + linux-headers \ + zlib-dev \ + libuv-dev \ + paxctl \ + binutils-gold \ + gnupg \ + curl \ + icu-dev \ + openssl-dev \ + && for key in \ + 9554F04D7259F04124DE6B476D5A82AC7E37093B \ + 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ + 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ + FD3A5288F042B6850C66B31F09FE44734EB7990E \ + 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ + DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ + B9AE9905FFD7803F25714661B63B535A4C206CA9 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + ; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ + && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --verify SHASUMS256.txt.asc \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt.asc | sha256sum -c - \ + && mkdir -p /usr/src \ + && tar -xJf "node-v$NODE_VERSION.tar.xz" -C /usr/src \ + && rm node-v$NODE_VERSION.tar.xz SHASUMS256.txt.asc \ + && cd "/usr/src/node-v$NODE_VERSION" \ + && ./configure --prefix=/usr --with-intl=system-icu --shared-zlib --shared-libuv --shared-openssl \ + && make -j$(getconf _NPROCESSORS_ONLN) -C out mksnapshot BUILDTYPE=Release \ + && paxctl -cm out/Release/mksnapshot \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && make install \ + && paxctl -cm /usr/bin/node \ + && cd / \ + && apk del --virtual .build-deps \ + && rm -rf \ + /usr/src/* \ + /usr/share/doc \ + /usr/share/man \ + /usr/share/doc \ + /tmp/* \ + /var/cache/apk/* \ + /root/.npm \ + /root/.node-gyp \ + /usr/lib/node_modules/npm/man \ + /usr/lib/node_modules/npm/doc \ + /usr/lib/node_modules/npm/html + +CMD [ "node" ] diff --git a/5.7/alpine/Dockerfile b/5.7/alpine/Dockerfile new file mode 100644 index 0000000000..a5aa16c03f --- /dev/null +++ b/5.7/alpine/Dockerfile @@ -0,0 +1,66 @@ +FROM alpine:latest + +ENV NPM_CONFIG_LOGLEVEL info +ENV NODE_VERSION=5.7.0 + +RUN apk --no-cache update \ + && apk --no-cache upgrade \ + && apk add --no-cache icu libintl libuv \ + && apk add --no-cache --virtual .build-deps \ + gcc \ + libgcc \ + g++ \ + libstdc++ \ + make \ + python \ + linux-headers \ + zlib-dev \ + libuv-dev \ + paxctl \ + binutils-gold \ + gnupg \ + curl \ + icu-dev \ + openssl-dev \ + && for key in \ + 9554F04D7259F04124DE6B476D5A82AC7E37093B \ + 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ + 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ + FD3A5288F042B6850C66B31F09FE44734EB7990E \ + 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ + DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ + B9AE9905FFD7803F25714661B63B535A4C206CA9 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + ; do \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ + done \ + && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --verify SHASUMS256.txt.asc \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt.asc | sha256sum -c - \ + && mkdir -p /usr/src \ + && tar -xJf "node-v$NODE_VERSION.tar.xz" -C /usr/src \ + && rm node-v$NODE_VERSION.tar.xz SHASUMS256.txt.asc \ + && cd "/usr/src/node-v$NODE_VERSION" \ + && ./configure --prefix=/usr --with-intl=system-icu --shared-zlib --shared-libuv --shared-openssl \ + && make -j$(getconf _NPROCESSORS_ONLN) -C out mksnapshot BUILDTYPE=Release \ + && paxctl -cm out/Release/mksnapshot \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && make install \ + && paxctl -cm /usr/bin/node \ + && cd / \ + && apk del --virtual .build-deps \ + && rm -rf \ + /usr/src/* \ + /usr/share/doc \ + /usr/share/man \ + /usr/share/doc \ + /tmp/* \ + /var/cache/apk/* \ + /root/.npm \ + /root/.node-gyp \ + /usr/lib/node_modules/npm/man \ + /usr/lib/node_modules/npm/doc \ + /usr/lib/node_modules/npm/html + +CMD [ "node" ] diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 3586548e63..2dd58d6b64 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -27,7 +27,7 @@ for version in "${versions[@]}"; do echo "$va: ${url}@${commit} $version" done - for variant in onbuild slim wheezy; do + for variant in onbuild slim wheezy alpine; do commit="$(git log -1 --format='format:%H' -- "$version/$variant")" echo for va in "${versionAliases[@]}"; do diff --git a/test-build.sh b/test-build.sh index f2910bfe33..98a2372da7 100755 --- a/test-build.sh +++ b/test-build.sh @@ -37,7 +37,7 @@ for version in "${versions[@]}"; do info "Build of $tag succeeded." fi - variants=( onbuild slim wheezy ) + variants=( onbuild slim wheezy alpine ) for variant in "${variants[@]}"; do info "Building $tag-$variant variant..." diff --git a/update-npm.sh b/update-npm.sh index ef8ddc9b7b..a2ddd67ceb 100755 --- a/update-npm.sh +++ b/update-npm.sh @@ -17,7 +17,7 @@ for version in "${versions[@]}"; do ( sed -E -i.bak ' s/^(ENV NPM_VERSION) .*/\1 '"$npmVersion"'/; - ' "$version/Dockerfile" "$version/slim/Dockerfile" "$version/wheezy/Dockerfile" - rm $version/Dockerfile.bak $version/slim/Dockerfile.bak $version/wheezy/Dockerfile.bak + ' "$version/Dockerfile" "$version/slim/Dockerfile" "$version/wheezy/Dockerfile" "$version/alpine/Dockerfile" + rm $version/Dockerfile.bak $version/slim/Dockerfile.bak $version/wheezy/Dockerfile.bak $version/alpine/Dockerfile.bak ) done diff --git a/update.sh b/update.sh index e5f4296075..af36c0e879 100755 --- a/update.sh +++ b/update.sh @@ -14,8 +14,8 @@ for version in "${versions[@]}"; do ( sed -E -i.bak ' s/^(ENV NODE_VERSION) .*/\1 '"$version.$fullVersion"'/; - ' "$version/Dockerfile" "$version/slim/Dockerfile" "$version/wheezy/Dockerfile" - rm $version/Dockerfile.bak $version/slim/Dockerfile.bak $version/wheezy/Dockerfile.bak + ' "$version/Dockerfile" "$version/slim/Dockerfile" "$version/wheezy/Dockerfile" "$version/alpine/Dockerfile" + rm $version/Dockerfile.bak $version/slim/Dockerfile.bak $version/wheezy/Dockerfile.bak $version/alpine/Dockerfile.bak sed -E -i.bak 's/^(FROM node):.*/\1:'"$version.$fullVersion"'/' "$version/onbuild/Dockerfile" rm $version/onbuild/Dockerfile.bak From 314ae205d750b4e8ea5a580409dc4f736007aa14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20HOUZ=C3=89?= Date: Fri, 26 Feb 2016 14:35:30 +0100 Subject: [PATCH 2/3] Give it a try on edge. --- 4.3/alpine/Dockerfile | 9 ++++----- 5.7/alpine/Dockerfile | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/4.3/alpine/Dockerfile b/4.3/alpine/Dockerfile index 5df1d8d50a..7f996ebdab 100644 --- a/4.3/alpine/Dockerfile +++ b/4.3/alpine/Dockerfile @@ -1,12 +1,11 @@ -FROM alpine:latest +FROM alpine:edge ENV NPM_CONFIG_LOGLEVEL info ENV NODE_VERSION=4.3.1 -RUN apk --no-cache update \ - && apk --no-cache upgrade \ - && apk add --no-cache icu libintl libuv \ - && apk add --no-cache --virtual .build-deps \ +RUN apk update --upgrade \ + && apk add icu libintl libuv \ + && apk add --virtual .build-deps \ gcc \ libgcc \ g++ \ diff --git a/5.7/alpine/Dockerfile b/5.7/alpine/Dockerfile index a5aa16c03f..772df74458 100644 --- a/5.7/alpine/Dockerfile +++ b/5.7/alpine/Dockerfile @@ -1,12 +1,11 @@ -FROM alpine:latest +FROM alpine:edge ENV NPM_CONFIG_LOGLEVEL info ENV NODE_VERSION=5.7.0 -RUN apk --no-cache update \ - && apk --no-cache upgrade \ - && apk add --no-cache icu libintl libuv \ - && apk add --no-cache --virtual .build-deps \ +RUN apk update --upgrade \ + && apk add icu libintl libuv \ + && apk add --virtual .build-deps \ gcc \ libgcc \ g++ \ From 0ed4d470e8add1100b4cb22a59beb87381360e07 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 26 Feb 2016 14:04:29 +0100 Subject: [PATCH 3/3] Improve download and install of dependencies Since we delete the cache at the end we can just drop the `--no-cache` and avoid downloadind the APKINDEX for every `apk` run. We also autodetect the runtime dependencies using `scanelf` and protect them using `--virtual`. --- 4.3/alpine/Dockerfile | 14 ++++++++++---- 5.7/alpine/Dockerfile | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/4.3/alpine/Dockerfile b/4.3/alpine/Dockerfile index 7f996ebdab..a67118653e 100644 --- a/4.3/alpine/Dockerfile +++ b/4.3/alpine/Dockerfile @@ -3,13 +3,11 @@ FROM alpine:edge ENV NPM_CONFIG_LOGLEVEL info ENV NODE_VERSION=4.3.1 -RUN apk update --upgrade \ - && apk add icu libintl libuv \ +RUN apk upgrade --update-cache \ && apk add --virtual .build-deps \ gcc \ - libgcc \ g++ \ - libstdc++ \ + libc-dev \ make \ python \ linux-headers \ @@ -21,6 +19,7 @@ RUN apk update --upgrade \ curl \ icu-dev \ openssl-dev \ + pax-utils \ && for key in \ 9554F04D7259F04124DE6B476D5A82AC7E37093B \ 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ @@ -48,6 +47,13 @@ RUN apk update --upgrade \ && make install \ && paxctl -cm /usr/bin/node \ && cd / \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/bin/node /usr/lib/node* \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u )" \ + && apk add --virtual .node-rundeps $runDeps \ && apk del --virtual .build-deps \ && rm -rf \ /usr/src/* \ diff --git a/5.7/alpine/Dockerfile b/5.7/alpine/Dockerfile index 772df74458..dfca1566d1 100644 --- a/5.7/alpine/Dockerfile +++ b/5.7/alpine/Dockerfile @@ -3,13 +3,11 @@ FROM alpine:edge ENV NPM_CONFIG_LOGLEVEL info ENV NODE_VERSION=5.7.0 -RUN apk update --upgrade \ - && apk add icu libintl libuv \ +RUN apk upgrade --update-cache \ && apk add --virtual .build-deps \ gcc \ - libgcc \ g++ \ - libstdc++ \ + libc-dev \ make \ python \ linux-headers \ @@ -21,6 +19,7 @@ RUN apk update --upgrade \ curl \ icu-dev \ openssl-dev \ + pax-utils \ && for key in \ 9554F04D7259F04124DE6B476D5A82AC7E37093B \ 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ @@ -48,6 +47,13 @@ RUN apk update --upgrade \ && make install \ && paxctl -cm /usr/bin/node \ && cd / \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/bin/node /usr/lib/node* \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u )" \ + && apk add --virtual .node-rundeps $runDeps \ && apk del --virtual .build-deps \ && rm -rf \ /usr/src/* \