Merge pull request #596 from kfarnung/node-cc

Add Dockerfile for node-chakracore
This commit is contained in:
Christopher Horrell 2018-02-09 09:12:47 -05:00 committed by GitHub
commit 8feaf8264e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 282 additions and 49 deletions

View File

@ -29,6 +29,7 @@ env:
- NODE_VERSION: '6'
- NODE_VERSION: '8'
- NODE_VERSION: '9'
- NODE_VERSION: 'chakracore/8'
matrix:
include:

View File

@ -51,7 +51,6 @@ RUN set -ex \
gpg --keyserver hkp://keyserver.pgp.com:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
done \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \

View File

@ -17,7 +17,8 @@ RUN set -ex \
; do \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" || \
gpg --keyserver hkp://keyserver.pgp.com:80 --recv-keys "$key" || \
gpg --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
done
ENV NODE_VERSION 8.9.4

View File

@ -51,8 +51,6 @@ RUN set -ex \
gpg --keyserver hkp://keyserver.pgp.com:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
done \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \

40
chakracore/8/Dockerfile Normal file
View File

@ -0,0 +1,40 @@
FROM buildpack-deps:jessie
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
ENV NODE_VERSION 8.9.4
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
&& curl -SLO "https://nodejs.org/download/chakracore-release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& curl -SLO --compressed "https://nodejs.org/download/chakracore-release/v$NODE_VERSION/SHASUMS256.txt" \
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
ENV YARN_VERSION 1.3.2
RUN set -ex \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" || \
gpg --keyserver hkp://keyserver.pgp.com:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
done \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& mkdir -p /opt/yarn \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz
CMD [ "node" ]

View File

@ -0,0 +1,40 @@
FROM buildpack-deps:jessie
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
ENV NODE_VERSION 0.0.0
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
&& curl -SLO "https://nodejs.org/download/chakracore-release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& curl -SLO --compressed "https://nodejs.org/download/chakracore-release/v$NODE_VERSION/SHASUMS256.txt" \
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
ENV YARN_VERSION 0.0.0
RUN set -ex \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" || \
gpg --keyserver hkp://keyserver.pgp.com:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
done \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& mkdir -p /opt/yarn \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz
CMD [ "node" ]

2
chakracore/architectures Normal file
View File

@ -0,0 +1,2 @@
bashbrew-arch variants
amd64 default

1
chakracore/config Normal file
View File

@ -0,0 +1 @@
baseuri https://nodejs.org/download/chakracore-release

1
config Normal file
View File

@ -0,0 +1 @@
baseuri https://nodejs.org/dist

View File

@ -2,6 +2,17 @@
# Utlity functions
info() {
printf "%s\\n" "$@"
}
fatal() {
printf "**********\\n"
printf "Fatal Error: %s\\n" "$@"
printf "**********\\n"
exit 1
}
# Get system architecture
#
# This is used to get the target architecture for docker image.
@ -40,10 +51,14 @@ function get_arch() {
# <architecutre 1> <supported variant 1 >,<supported variant 2>...
# <architecutre 2> <supported variant 1 >,<supported variant 2>...
function get_variants() {
local dir
dir=${1:-.}
shift
local arch
arch=$(get_arch)
local variants
variants=$(grep "^$arch" architectures | sed -E 's/'"$arch"'\s*//' | sed -E 's/,/ /g')
variants=$(grep "^$arch" "$dir/architectures" | sed -E 's/'"$arch"'[[:space:]]*//' | sed -E 's/,/ /g')
echo "$variants"
}
@ -58,15 +73,146 @@ function get_supported_arches () {
local version
local variant
local arches
local lines
local line
version="$1"; shift
variant="$1"; shift
# Get default supported arches
arches=$( grep "$variant" architectures 2>/dev/null | cut -d' ' -f1 )
lines=$( grep "$variant" "$(dirname "$version")"/architectures 2>/dev/null | cut -d' ' -f1 )
# Get version specific supported architectures if there is specialized information
if [ -a "$version"/architectures ]; then
arches=$( grep "$variant" "$version"/architectures 2>/dev/null | cut -d' ' -f1 )
lines=$( grep "$variant" "$version"/architectures 2>/dev/null | cut -d' ' -f1 )
fi
echo "$arches"
while IFS='' read -r line; do
arches+=( "$line" )
done <<< "$lines"
echo "${arches[@]}"
}
# Get configuration values from the config file
#
# The configuration entries are simple key/value pairs which are whitespace separated.
function get_config () {
local dir
dir=${1:-.}
shift
local name
name=$1
shift
local value
value=$(grep "^$name" "$dir/config" | sed -E 's/'"$name"'[[:space:]]*//')
echo "$value"
}
# Get available versions for a given path
#
# If full or partial versions are provided then they are processed and
# validated. e.g. "4 chakracore" returns "4 chakracore/8" since it processed the
# chakracore entry and found it to be a fork rather than a complete version.
#
# The result is a list of valid versions.
function get_versions () {
local prefix
prefix=${1:-.}
shift
local versions
local dirs=( "$@" )
if [ ${#dirs[@]} -eq 0 ]; then
IFS=' ' read -ra dirs <<< "$(echo "${prefix%/}/"*/)"
fi
for dir in "${dirs[@]}"; do
if [ -a "$dir/config" ]; then
local subdirs
IFS=' ' read -ra subdirs <<< "$(get_versions "${dir#./}")"
for subdir in "${subdirs[@]}"; do
versions+=( "$subdir" )
done
elif [ -a "$dir/Dockerfile" ]; then
versions+=( "${dir#./}" )
fi
done
if [ ${#versions[@]} -gt 0 ]; then
echo "${versions[@]%/}"
fi
}
function get_fork_name () {
local version
version=$1
shift
IFS='/' read -ra versionparts <<< "$version"
if [ ${#versionparts[@]} -gt 1 ]; then
echo "${versionparts[0]}"
fi
}
function get_full_version () {
local version
version=$1
shift
grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3
}
function get_major_minor_version () {
local version
version=$1
shift
local fullversion
fullversion=$(get_full_version "$version")
echo "$(echo "$fullversion" | cut -d'.' -f1).$(echo "$fullversion" | cut -d'.' -f2)"
}
function get_tag () {
local version
version=$1
shift
local versiontype
versiontype=${1:-full}
shift
local tagversion
if [ "$versiontype" = full ]; then
tagversion=$(get_full_version "$version")
elif [ "$versiontype" = majorminor ]; then
tagversion=$(get_major_minor_version "$version")
fi
local tagparts
IFS=' ' read -ra tagparts <<< "$(get_fork_name "$version") $tagversion"
IFS='-'; echo "${tagparts[*]}"; unset IFS
}
function sort_versions () {
local versions=( "$@" )
local sorted
local lines
local line
IFS=$'\n'
lines="${versions[*]}"
unset IFS
while IFS='' read -r line; do
sorted+=( "$line" )
done <<< "$(echo "$lines" | grep "^[0-9]" | sort -r)"
while IFS='' read -r line; do
sorted+=( "$line" )
done <<< "$(echo "$lines" | grep -v "^[0-9]" | sort -r)"
echo "${sorted[@]}"
}

View File

@ -13,18 +13,17 @@ array_6='6 boron';
array_8='8 carbon';
# shellcheck disable=SC2034
array_9='9 latest';
# shellcheck disable=SC2034
array_chakracore_8='chakracore-8 chakracore';
cd "$(cd "${0%/*}" && pwd -P)";
self="$(basename "${BASH_SOURCE[0]}")"
versions=( */ )
versions=( "${versions[@]%/}" )
IFS=' ' read -ra versions <<< "$(get_versions)"
IFS=' ' read -ra versions <<< "$(sort_versions "${versions[@]}")"
url='https://github.com/nodejs/docker-node'
# sort version numbers with highest first
IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -r) ); unset IFS
# get the most recent commit which modified any of "$@"
fileCommit() {
git log -1 --format='format:%H' HEAD -- "$@"
@ -43,18 +42,25 @@ join() {
echo "${out#$sep}"
}
get_stub() {
local version="$1"; shift
IFS='/' read -ra versionparts <<< "$version"
local stub; eval stub="$(join '_' "${versionparts[@]}" | awk -F. '{ print "$array_" $1 }')";
echo "$stub"
}
for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories
[ -f "$version/Dockerfile" ] || continue
eval stub="$(echo "$version" | awk -F. '{ print "$array_" $1 }')";
stub=$(get_stub "$version")
commit="$(fileCommit "$version")"
fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)"
minorVersion="$(echo "$fullVersion" | cut -d'.' -f2)"
fullVersion="$(get_tag "$version" full)"
majorMinorVersion="$(get_tag "$version" majorminor)"
versionAliases=( $fullVersion $version.$minorVersion ${stub} )
IFS=' ' read -ra versionAliases <<< "$fullVersion $majorMinorVersion $stub"
# Get supported architectures for a specific version. See details in function.sh
supportedArches=( $(get_supported_arches "$version" "default") )
IFS=' ' read -ra supportedArches <<< "$(get_supported_arches "$version" "default")"
echo "Tags: $(join ', ' "${versionAliases[@]}")"
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
@ -64,7 +70,7 @@ for version in "${versions[@]}"; do
# Get supported variants according to the target architecture.
# See details in function.sh
variants=$(get_variants | tr ' ' '\n')
variants=$(get_variants "$(dirname "$version")")
for variant in $variants; do
# Skip non-docker directories
[ -f "$version/$variant/Dockerfile" ] || continue
@ -76,7 +82,7 @@ for version in "${versions[@]}"; do
variantAliases=( "${variantAliases[@]//latest-/}" )
# Get supported architectures for a specific version and variant.
# See details in function.sh
supportedArches=( $(get_supported_arches "$version" "$variant") )
IFS=' ' read -ra supportedArches <<< "$(get_supported_arches "$version" "$variant")"
echo "Tags: $(join ', ' "${variantAliases[@]}")"
echo "Architectures: $(join ', ' "${supportedArches[@]}")"

View File

@ -3,34 +3,22 @@
# Run a test build for all images.
set -uo pipefail
IFS=$'\n\t'
. functions.sh
info() {
printf "%s\n" "$@"
}
fatal() {
printf "**********\n"
printf "%s\n" "$@"
printf "**********\n"
exit 1
}
cd "$(cd "${0%/*}" && pwd -P)" || exit;
versions=( "$@" )
IFS=' ' read -ra versions <<< "$(get_versions . "$@")"
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fatal "No valid versions found!"
fi
versions=( "${versions[@]%/}" )
for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories
[ -f "$version/Dockerfile" ] || continue
tag=$(grep "ENV NODE_VERSION" "$version/Dockerfile" | cut -d' ' -f3)
tag=$(get_tag "$version")
full_version=$(get_full_version "$version")
info "Building $tag..."
@ -40,14 +28,14 @@ for version in "${versions[@]}"; do
info "Build of $tag succeeded."
OUTPUT=$(docker run --rm -it node:"$tag" node -e "process.stdout.write(process.versions.node)")
if [ "$OUTPUT" != "$tag" ]; then
if [ "$OUTPUT" != "$full_version" ]; then
fatal "Test of $tag failed!"
fi
info "Test of $tag succeeded."
# Get supported variants according to the target architecture.
# See details in function.sh
variants=$(get_variants | tr ' ' '\n')
variants=$(get_variants "$(dirname "$version")")
for variant in $variants; do
# Skip non-docker directories
@ -61,7 +49,7 @@ for version in "${versions[@]}"; do
info "Build of $tag-$variant succeeded."
OUTPUT=$(docker run --rm -it node:"$tag-$variant" node -e "process.stdout.write(process.versions.node)")
if [ "$OUTPUT" != "$tag" ]; then
if [ "$OUTPUT" != "$full_version" ]; then
fatal "Test of $tag-$variant failed!"
fi
info "Test of $tag-$variant succeeded."

View File

@ -1,15 +1,14 @@
#!/bin/bash
set -e
set -ue
. functions.sh
cd "$(cd "${0%/*}" && pwd -P)";
versions=( "$@" )
IFS=' ' read -ra versions <<< "$(get_versions . "$@")"
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fatal "No valid versions found!"
fi
versions=( "${versions[@]%/}" )
# Global variables
# Get architecure and use this as target architecture for docker image
@ -21,6 +20,10 @@ yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
function update_node_version {
local baseuri=$1
shift
local version=$1
shift
local template=$1
shift
local dockerfile=$1
@ -31,12 +34,12 @@ function update_node_version {
shift
fi
fullVersion="$(curl -sSL --compressed 'https://nodejs.org/dist' | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -d'.' -f2,3| sort -n | tail -1)"
fullVersion="$(curl -sSL --compressed "$baseuri" | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -d'.' -f2,3| sort -n | tail -1)"
(
cp "$template" "$dockerfile"
local fromprefix=
if [[ "$arch" != "amd64" && "$variant" != "onbuild" ]]; then
fromprefix="$arch\/"
fromprefix="$arch\\/"
fi
sed -E -i.bak 's/^FROM (.*)/FROM '"$fromprefix"'\1/' "$dockerfile" && rm "$dockerfile".bak
@ -53,16 +56,23 @@ for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories
[ -f "$version/Dockerfile" ] || continue
update_node_version "Dockerfile.template" "$version/Dockerfile"
info "Updating version $version..."
parentpath=$(dirname "$version")
versionnum=$(basename "$version")
baseuri=$(get_config "$parentpath" "baseuri")
update_node_version "$baseuri" "$versionnum" "$parentpath/Dockerfile.template" "$version/Dockerfile"
# Get supported variants according the target architecture
# See details in function.sh
variants=$(get_variants)
variants=$(get_variants "$parentpath")
for variant in $variants; do
# Skip non-docker directories
[ -f "$version/$variant/Dockerfile" ] || continue
update_node_version "Dockerfile-$variant.template" "$version/$variant/Dockerfile" "$variant"
update_node_version "$baseuri" "$versionnum" "$parentpath/Dockerfile-$variant.template" "$version/$variant/Dockerfile" "$variant"
done
done
info "Done!"