Support Linux on ppc64le
- Add an architectures file to list supported architectures and variants. - Add new `ARCH` ENV into Dockerfile. It represents the architecture. - Add a functions.sh to put utility functions, including - get_arch: get the current running architecture. - get_variants: get corresponding supported variants based on the running architecture. Signed-off-by: Yihong Wang <yh.wang@ibm.com>
This commit is contained in:
parent
ec6da31525
commit
8305e4c32f
|
@ -24,15 +24,21 @@ ENV NPM_CONFIG_LOGLEVEL info
|
||||||
ENV NODE_VERSION 0.0.0
|
ENV NODE_VERSION 0.0.0
|
||||||
|
|
||||||
RUN buildDeps='xz-utils' \
|
RUN buildDeps='xz-utils' \
|
||||||
|
&& ARCH= && dpkgArch="$(dpkg --print-architecture)" \
|
||||||
|
&& case "${dpkgArch##*-}" in \
|
||||||
|
amd64) ARCH='x64';; \
|
||||||
|
ppc64el) ARCH='ppc64le';; \
|
||||||
|
*) echo "unsupported architecture"; exit 1 ;; \
|
||||||
|
esac \
|
||||||
&& set -x \
|
&& set -x \
|
||||||
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends \
|
&& apt-get update && apt-get install -y $buildDeps --no-install-recommends \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
|
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
|
||||||
&& curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
&& curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
||||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||||
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
||||||
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
|
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 \
|
||||||
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||||
&& apt-get purge -y --auto-remove $buildDeps \
|
&& apt-get purge -y --auto-remove $buildDeps \
|
||||||
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,18 @@ RUN set -ex \
|
||||||
ENV NPM_CONFIG_LOGLEVEL info
|
ENV NPM_CONFIG_LOGLEVEL info
|
||||||
ENV NODE_VERSION 0.0.0
|
ENV NODE_VERSION 0.0.0
|
||||||
|
|
||||||
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
|
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
|
||||||
|
&& case "${dpkgArch##*-}" in \
|
||||||
|
amd64) ARCH='x64';; \
|
||||||
|
ppc64el) ARCH='ppc64le';; \
|
||||||
|
*) echo "unsupported architecture"; exit 1 ;; \
|
||||||
|
esac \
|
||||||
|
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
|
||||||
&& curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
&& curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
||||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||||
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
||||||
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
|
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 \
|
||||||
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||||
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
||||||
|
|
||||||
ENV YARN_VERSION 0.0.0
|
ENV YARN_VERSION 0.0.0
|
||||||
|
|
|
@ -23,12 +23,18 @@ RUN set -ex \
|
||||||
ENV NPM_CONFIG_LOGLEVEL info
|
ENV NPM_CONFIG_LOGLEVEL info
|
||||||
ENV NODE_VERSION 0.0.0
|
ENV NODE_VERSION 0.0.0
|
||||||
|
|
||||||
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
|
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
|
||||||
|
&& case "${dpkgArch##*-}" in \
|
||||||
|
amd64) ARCH='x64';; \
|
||||||
|
ppc64el) ARCH='ppc64le';; \
|
||||||
|
*) echo "unsupported architecture"; exit 1 ;; \
|
||||||
|
esac \
|
||||||
|
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
|
||||||
&& curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
&& curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
||||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||||
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
||||||
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
|
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 \
|
||||||
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||||
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
||||||
|
|
||||||
ENV YARN_VERSION 0.0.0
|
ENV YARN_VERSION 0.0.0
|
||||||
|
|
|
@ -137,7 +137,10 @@ $ docker run node npm --loglevel=warn ...
|
||||||
|
|
||||||
The `node` images come in many flavors, each designed for a specific use case.
|
The `node` images come in many flavors, each designed for a specific use case.
|
||||||
All of the images contain pre-installed versions of `node`,
|
All of the images contain pre-installed versions of `node`,
|
||||||
[`npm`](https://www.npmjs.com/), and [`yarn`](https://yarnpkg.com).
|
[`npm`](https://www.npmjs.com/), and [`yarn`](https://yarnpkg.com). For each
|
||||||
|
supported architecutre, the supported variants are different. In the file:
|
||||||
|
[architectures](./architectures), it lists all supported variants for all of
|
||||||
|
the architecures that we support now.
|
||||||
|
|
||||||
## `node:<version>`
|
## `node:<version>`
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
bashbrew-arch variants
|
||||||
|
x64 alpine,onbuild,slim,wheezy
|
||||||
|
ppc64le onbuild,slim
|
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Utlity functions
|
||||||
|
|
||||||
|
# Get system architecture
|
||||||
|
#
|
||||||
|
# This is used to get the target architecture for docker image.
|
||||||
|
# For crossing building, we need a way to specify the target
|
||||||
|
# architecutre manually.
|
||||||
|
function get_arch() {
|
||||||
|
local arch
|
||||||
|
case $(uname -m) in
|
||||||
|
x86_64)
|
||||||
|
arch="x64"
|
||||||
|
;;
|
||||||
|
ppc64le)
|
||||||
|
arch="ppc64le"
|
||||||
|
;;
|
||||||
|
s390x)
|
||||||
|
arch="s390x"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$0 does not support architecture $arch ... aborting"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "$arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get corresponding variants based on the architecture.
|
||||||
|
# All supported variants of each supported architecutre are listed in a
|
||||||
|
# file - 'architectures'. Its format is:
|
||||||
|
# <architecutre 1> <supported variant 1 >,<supported variant 2>...
|
||||||
|
# <architecutre 2> <supported variant 1 >,<supported variant 2>...
|
||||||
|
function get_variants() {
|
||||||
|
local arch
|
||||||
|
arch=$(get_arch)
|
||||||
|
local variants
|
||||||
|
variants=$(grep "$arch" architectures | sed -E 's/'"$arch"'\s*//' | sed -E 's/,/ /g')
|
||||||
|
echo "$variants"
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
. functions.sh
|
||||||
|
|
||||||
hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
|
hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
|
||||||
|
|
||||||
|
@ -57,7 +58,9 @@ for version in "${versions[@]}"; do
|
||||||
echo "Directory: ${version}"
|
echo "Directory: ${version}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
variants=$(echo "$version"/*/ | xargs -n1 basename)
|
# Get supported variants according to the target architecture.
|
||||||
|
# See details in function.sh
|
||||||
|
variants=$(get_variants | tr ' ' '\n')
|
||||||
for variant in $variants; do
|
for variant in $variants; do
|
||||||
# Skip non-docker directories
|
# Skip non-docker directories
|
||||||
[ -f "$version/$variant/Dockerfile" ] || continue
|
[ -f "$version/$variant/Dockerfile" ] || continue
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
. functions.sh
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
printf "%s\n" "$@"
|
printf "%s\n" "$@"
|
||||||
}
|
}
|
||||||
|
@ -43,7 +45,9 @@ for version in "${versions[@]}"; do
|
||||||
fi
|
fi
|
||||||
info "Test of $tag succeeded."
|
info "Test of $tag succeeded."
|
||||||
|
|
||||||
variants=$(echo "$version"/*/ | xargs -n1 basename)
|
# Get supported variants according to the target architecture.
|
||||||
|
# See details in function.sh
|
||||||
|
variants=$(get_variants | tr ' ' '\n')
|
||||||
|
|
||||||
for variant in $variants; do
|
for variant in $variants; do
|
||||||
# Skip non-docker directories
|
# Skip non-docker directories
|
||||||
|
|
54
update.sh
54
update.sh
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
. functions.sh
|
||||||
|
|
||||||
cd "$(cd "${0%/*}" && pwd -P)";
|
cd "$(cd "${0%/*}" && pwd -P)";
|
||||||
|
|
||||||
versions=( "$@" )
|
versions=( "$@" )
|
||||||
|
@ -9,22 +11,39 @@ if [ ${#versions[@]} -eq 0 ]; then
|
||||||
fi
|
fi
|
||||||
versions=( "${versions[@]%/}" )
|
versions=( "${versions[@]%/}" )
|
||||||
|
|
||||||
|
# Global variables
|
||||||
template=
|
# Get architecure and use this as target architecture for docker image
|
||||||
dockerfile=
|
# See details in function.sh
|
||||||
|
# TODO: Should be able to specify target architecture manually
|
||||||
|
arch=$(get_arch)
|
||||||
|
|
||||||
yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
|
yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
|
||||||
|
|
||||||
function update_node_version {
|
function update_node_version {
|
||||||
|
|
||||||
|
local template=$1
|
||||||
|
shift
|
||||||
|
local dockerfile=$1
|
||||||
|
shift
|
||||||
|
local variant=
|
||||||
|
if [[ $# -eq 1 ]]; then
|
||||||
|
variant=$1
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
fullVersion="$(curl -sSL --compressed 'https://nodejs.org/dist' | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -f 3 -d . | sort -n | tail -1)"
|
fullVersion="$(curl -sSL --compressed 'https://nodejs.org/dist' | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -f 3 -d . | sort -n | tail -1)"
|
||||||
(
|
(
|
||||||
cp $template $dockerfile
|
cp "$template" "$dockerfile"
|
||||||
sed -E -i.bak 's/^(ENV NODE_VERSION |FROM node:).*/\1'"$version.$fullVersion"'/' "$dockerfile"
|
local fromprefix=
|
||||||
rm "$dockerfile.bak"
|
if [[ "$arch" != "x64" && "$variant" != "onbuild" ]]; then
|
||||||
sed -E -i.bak 's/^(ENV YARN_VERSION ).*/\1'"$yarnVersion"'/' "$dockerfile"
|
fromprefix="$arch\/"
|
||||||
rm "$dockerfile.bak"
|
fi
|
||||||
if [[ "${version/.*/}" -ge 8 ]]; then
|
|
||||||
sed -E -i.bak 's/FROM alpine:3.4/FROM alpine:3.6/' "$dockerfile"
|
sed -E -i.bak 's/^FROM (.*)/FROM '"$fromprefix"'\1/' "$dockerfile" && rm "$dockerfile".bak
|
||||||
|
sed -E -i.bak 's/^(ENV NODE_VERSION |FROM .*node:).*/\1'"$version.$fullVersion"'/' "$dockerfile" && rm "$dockerfile".bak
|
||||||
|
sed -E -i.bak 's/^(ENV YARN_VERSION ).*/\1'"$yarnVersion"'/' "$dockerfile" && rm "$dockerfile".bak
|
||||||
|
if [[ "${version/.*/}" -ge 8 || "$arch" = "ppc64le" ]]; then
|
||||||
|
sed -E -i.bak 's/FROM (.*)alpine:3.4/FROM \1alpine:3.6/' "$dockerfile"
|
||||||
rm "$dockerfile.bak"
|
rm "$dockerfile.bak"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
@ -34,21 +53,16 @@ for version in "${versions[@]}"; do
|
||||||
# Skip "docs" and other non-docker directories
|
# Skip "docs" and other non-docker directories
|
||||||
[ -f "$version/Dockerfile" ] || continue
|
[ -f "$version/Dockerfile" ] || continue
|
||||||
|
|
||||||
template="Dockerfile.template"
|
update_node_version "Dockerfile.template" "$version/Dockerfile"
|
||||||
dockerfile="$version/Dockerfile"
|
|
||||||
|
|
||||||
update_node_version
|
# Get supported variants according the target architecture
|
||||||
|
# See details in function.sh
|
||||||
variants=$(echo "$version"/*/ | xargs -n1 basename)
|
variants=$(get_variants)
|
||||||
|
|
||||||
for variant in $variants; do
|
for variant in $variants; do
|
||||||
# Skip non-docker directories
|
# Skip non-docker directories
|
||||||
[ -f "$version/$variant/Dockerfile" ] || continue
|
[ -f "$version/$variant/Dockerfile" ] || continue
|
||||||
|
update_node_version "Dockerfile-$variant.template" "$version/$variant/Dockerfile" "$variant"
|
||||||
template="Dockerfile-$variant.template"
|
|
||||||
dockerfile="$version/$variant/Dockerfile"
|
|
||||||
|
|
||||||
update_node_version
|
|
||||||
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue