Created
April 11, 2017 23:29
-
-
Save yoshuawuyts/b8984db024034668ca400a07beeeb535 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# from https://raw.githubusercontent.com/mhart/alpine-node/master/Dockerfile | |
VERSION='v6.10.2' | |
NPM_VERSION='3' | |
CONFIG_FLAGS="--fully-static --without-npm" | |
DEL_PKGS="libstdc++" | |
RM_DIRS=/usr/include | |
apk add --no-cache curl make gcc g++ python linux-headers binutils-gold gnupg libstdc++ && \ | |
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys \ | |
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ | |
FD3A5288F042B6850C66B31F09FE44734EB7990E \ | |
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ | |
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ | |
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ | |
B9AE9905FFD7803F25714661B63B535A4C206CA9 \ | |
56730D5401028683275BD23C23EFEFE93C4CFFFE && \ | |
curl -sSLO https://nodejs.org/dist/${VERSION}/node-${VERSION}.tar.xz && \ | |
curl -sSL https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc | gpg --batch --decrypt | \ | |
grep " node-${VERSION}.tar.xz\$" | sha256sum -c | grep . && \ | |
tar -xf node-${VERSION}.tar.xz && \ | |
cd node-${VERSION} && \ | |
./configure --prefix=/usr ${CONFIG_FLAGS} && \ | |
make -j$(getconf _NPROCESSORS_ONLN) && \ | |
make install && \ | |
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++ python linux-headers binutils-gold gnupg ${DEL_PKGS} && \ | |
rm -rf ${RM_DIRS} /node-${VERSION}* /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 /usr/lib/node_modules/npm/scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Creates a systemd-nspawn container with Alpine | |
MIRROR=http://nl.alpinelinux.org/alpine | |
ARCH=x86_64 | |
VERSION=v3.5 | |
APKTOOLS_VERSION=2.6.8-r2 | |
if [ $UID -ne 0 ]; then | |
echo "run this script as root" >&2 | |
exit 1 | |
fi | |
dest="alpine2" | |
node_dest="$dest/root" | |
apkdir=$(mktemp -d) | |
hostarch=x86 | |
[ $(uname -m) == x86_64 ] && hostarch=x86_64 | |
wget -qO- $MIRROR/latest-stable/main/$hostarch/apk-tools-static-$APKTOOLS_VERSION.apk \ | |
| tar -xz -C $apkdir | |
$apkdir/sbin/apk.static \ | |
-X $MIRROR/$VERSION/main -U \ | |
--allow-untrusted --root "$dest" \ | |
--initdb add alpine-base | |
mkdir -p "$dest"/{etc/apk,root} | |
printf 'nameserver 208.67.222.222\nnameserver 2620:0:ccc::2' >"$dest"/etc/resolv.conf | |
printf '%s/%s/main\n' $MIRROR $VERSION >"$dest"/etc/apk/repositories | |
sed '/tty[0-9]:/ s/^/#/' -i "$dest"/etc/inittab | |
printf 'console::respawn:/sbin/getty 38400 console\n' >>"$dest"/etc/inittab | |
for s in hostname bootmisc syslog; do | |
ln -s /etc/init.d/$s "$dest"/etc/runlevels/boot/$s | |
done | |
for s in killprocs savecache; do | |
ln -s /etc/init.d/$s "$dest"/etc/runlevels/shutdown/$s | |
done | |
# copy node build script | |
cp ./build-node "$node_dest" | |
chmod +x "$node_dest" | |
# mv alpine /var/lib/machines/alpine | |
systemd-nspawn -D "$dest" '/root/build-node' | |
rm -r $apkdir | |
echo "" | |
echo "Your Alpine container was created successfully." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code sources: