diff --git a/.travis.yml b/.travis.yml index 85a49c849..7d9cd77f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,7 +87,7 @@ jobs: - stage: Build env: - NODE_VERSION: "10" - - VARIANT: "default" + - VARIANT: "jessie" - stage: Build env: @@ -107,7 +107,7 @@ jobs: - stage: Build env: - NODE_VERSION: "6" - - VARIANT: "default" + - VARIANT: "jessie" - stage: Build env: @@ -132,7 +132,7 @@ jobs: - stage: Build env: - NODE_VERSION: "8" - - VARIANT: "default" + - VARIANT: "jessie" - stage: Build env: @@ -157,7 +157,7 @@ jobs: - stage: Build env: - NODE_VERSION: "9" - - VARIANT: "default" + - VARIANT: "jessie" - stage: Build env: diff --git a/10/Dockerfile b/10/jessie/Dockerfile similarity index 100% rename from 10/Dockerfile rename to 10/jessie/Dockerfile diff --git a/6/architectures b/6/architectures index 4c3285054..f6a742740 100644 --- a/6/architectures +++ b/6/architectures @@ -1,7 +1,7 @@ bashbrew-arch variants -arm32v7 default,onbuild,slim,stretch -arm64v8 default,onbuild,slim,stretch -amd64 default,alpine,onbuild,slim,stretch -i386 default,onbuild,slim,stretch -ppc64le default,onbuild,slim,stretch -s390x default,onbuild,slim,stretch +arm32v7 jessie,onbuild,slim,stretch +arm64v8 jessie,onbuild,slim,stretch +amd64 jessie,alpine,onbuild,slim,stretch +i386 jessie,onbuild,slim,stretch +ppc64le jessie,onbuild,slim,stretch +s390x jessie,onbuild,slim,stretch diff --git a/6/Dockerfile b/6/jessie/Dockerfile similarity index 100% rename from 6/Dockerfile rename to 6/jessie/Dockerfile diff --git a/6/onbuild/Dockerfile b/6/onbuild/Dockerfile index 175902050..23343a950 100644 --- a/6/onbuild/Dockerfile +++ b/6/onbuild/Dockerfile @@ -1,4 +1,4 @@ -FROM node:6.14.2 +FROM node:6.14.2-jessie RUN mkdir -p /usr/src/app WORKDIR /usr/src/app diff --git a/8/Dockerfile b/8/jessie/Dockerfile similarity index 100% rename from 8/Dockerfile rename to 8/jessie/Dockerfile diff --git a/8/onbuild/Dockerfile b/8/onbuild/Dockerfile index 38e63fc6c..5dae691fa 100644 --- a/8/onbuild/Dockerfile +++ b/8/onbuild/Dockerfile @@ -1,4 +1,4 @@ -FROM node:8.11.2 +FROM node:8.11.2-jessie RUN mkdir -p /usr/src/app WORKDIR /usr/src/app diff --git a/9/Dockerfile b/9/jessie/Dockerfile similarity index 100% rename from 9/Dockerfile rename to 9/jessie/Dockerfile diff --git a/9/onbuild/Dockerfile b/9/onbuild/Dockerfile index b04d80bd0..ffac71350 100644 --- a/9/onbuild/Dockerfile +++ b/9/onbuild/Dockerfile @@ -1,4 +1,4 @@ -FROM node:9.11.1 +FROM node:9.11.1-jessie RUN mkdir -p /usr/src/app WORKDIR /usr/src/app diff --git a/Dockerfile.template b/Dockerfile-jessie.template similarity index 100% rename from Dockerfile.template rename to Dockerfile-jessie.template diff --git a/Dockerfile-onbuild.template b/Dockerfile-onbuild.template index 59e58c9c6..5697066cb 100644 --- a/Dockerfile-onbuild.template +++ b/Dockerfile-onbuild.template @@ -1,4 +1,4 @@ -FROM node:0.0.0 +FROM node:0.0.0-jessie RUN mkdir -p /usr/src/app WORKDIR /usr/src/app diff --git a/architectures b/architectures index 55710f824..1a9b7a2dd 100644 --- a/architectures +++ b/architectures @@ -1,8 +1,8 @@ bashbrew-arch variants arm32v6 alpine -arm32v7 default,onbuild,slim,stretch -arm64v8 default,alpine,onbuild,slim,stretch -amd64 default,alpine,onbuild,slim,stretch -i386 default,alpine,onbuild,slim,stretch -ppc64le default,alpine,onbuild,slim,stretch -s390x default,alpine,onbuild,slim,stretch +arm32v7 jessie,onbuild,slim,stretch +arm64v8 jessie,alpine,onbuild,slim,stretch +amd64 jessie,alpine,onbuild,slim,stretch +i386 jessie,alpine,onbuild,slim,stretch +ppc64le jessie,alpine,onbuild,slim,stretch +s390x jessie,alpine,onbuild,slim,stretch diff --git a/config b/config index 5b8db1266..20c552259 100644 --- a/config +++ b/config @@ -1,2 +1,3 @@ baseuri https://nodejs.org/dist +default_variant jessie alpine_version 3.7 diff --git a/functions.sh b/functions.sh index 732eb8157..ea2713600 100755 --- a/functions.sh +++ b/functions.sh @@ -145,6 +145,9 @@ function get_versions() { local versions local dirs=("$@") + + local default_variant + default_variant=$(get_config "./" "default_variant") if [ ${#dirs[@]} -eq 0 ]; then IFS=' ' read -ra dirs <<<"$(echo "${prefix%/}/"*/)" fi @@ -156,7 +159,7 @@ function get_versions() { for subdir in "${subdirs[@]}"; do versions+=("${subdir}") done - elif [ -a "${dir}/Dockerfile" ]; then + elif [ -a "${dir}/Dockerfile" ] || [ -a "${dir}/${default_variant}/Dockerfile" ]; then versions+=("${dir#./}") fi done @@ -182,7 +185,14 @@ function get_full_version() { version=$1 shift - grep -m1 'ENV NODE_VERSION ' "${version}/Dockerfile" | cut -d' ' -f3 + local default_dockerfile + if [ -f "${version}/${default_variant}/Dockerfile" ]; then + default_dockerfile="${version}/${default_variant}/Dockerfile" + else + default_dockerfile="${version}/Dockerfile" + fi + + grep -m1 'ENV NODE_VERSION ' "${default_dockerfile}" | cut -d' ' -f3 } function get_major_minor_version() { diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 6fde44a20..e2ac5b393 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -19,6 +19,8 @@ array_chakracore_8='chakracore-8' # shellcheck disable=SC2034 array_chakracore_10='chakracore-10 chakracore' +default_variant=$(get_config "./" "default_variant") + cd "$(cd "${0%/*}" && pwd -P)" self="$(basename "${BASH_SOURCE[0]}")" @@ -58,7 +60,7 @@ get_stub() { for version in "${versions[@]}"; do # Skip "docs" and other non-docker directories - [ -f "${version}/Dockerfile" ] || continue + [ -f "${version}/Dockerfile" ] || [ -f "${version}/${default_variant}/Dockerfile" ] || continue stub=$(get_stub "${version}") commit="$(fileCommit "${version}")" @@ -66,14 +68,17 @@ for version in "${versions[@]}"; do majorMinorVersion="$(get_tag "${version}" majorminor)" IFS=' ' read -ra versionAliases <<<"$fullVersion $majorMinorVersion $stub" - # Get supported architectures for a specific version. See details in function.sh - IFS=' ' read -ra supportedArches <<<"$(get_supported_arches "${version}" "default")" - echo "Tags: $(join ', ' "${versionAliases[@]}")" - echo "Architectures: $(join ', ' "${supportedArches[@]}")" - echo "GitCommit: ${commit}" - echo "Directory: ${version}" - echo + if [ -f "${version}/Dockerfile" ]; then + # Get supported architectures for a specific version. See details in function.sh + IFS=' ' read -ra supportedArches <<<"$(get_supported_arches "${version}" "default")" + + echo "Tags: $(join ', ' "${versionAliases[@]}")" + echo "Architectures: $(join ', ' "${supportedArches[@]}")" + echo "GitCommit: ${commit}" + echo "Directory: ${version}" + echo + fi # Get supported variants according to the target architecture. # See details in function.sh @@ -87,6 +92,10 @@ for version in "${versions[@]}"; do slash='/' variantAliases=("${versionAliases[@]/%/-${variant//${slash}/-}}") variantAliases=("${variantAliases[@]//latest-/}") + if [ "${variant}" = "${default_variant}" ]; then + variantAliases+=("${versionAliases[@]}") + fi + # Get supported architectures for a specific version and variant. # See details in function.sh IFS=' ' read -ra supportedArches <<<"$(get_supported_arches "${version}" "${variant}")" diff --git a/test-build.sh b/test-build.sh index 65416568b..e76787d38 100755 --- a/test-build.sh +++ b/test-build.sh @@ -12,6 +12,8 @@ set -uo pipefail IFS=',' read -ra versions_arg <<<"${1:-}" IFS=',' read -ra variant_arg <<<"${2:-}" +default_variant=$(get_config "./" "default_variant") + function build() { local version local tag @@ -28,6 +30,9 @@ function build() { if [ -z "${variant}" ]; then full_tag="${tag}" path="${version}/${variant}" + elif [ "${variant}" = "default" ]; then + full_tag="${tag}" + path="${version}" else full_tag="${tag}-${variant}" path="${version}/${variant}" @@ -53,7 +58,7 @@ fi for version in "${versions[@]}"; do # Skip "docs" and other non-docker directories - [ -f "${version}/Dockerfile" ] || continue + [ -f "${version}/Dockerfile" ] || [ -a "${version}/${default_variant}/Dockerfile" ] || continue tag=$(get_tag "${version}") full_version=$(get_full_version "${version}") @@ -62,15 +67,14 @@ for version in "${versions[@]}"; do # See details in function.sh IFS=' ' read -ra variants <<<"$(get_variants "$(dirname "${version}")" "${variant_arg[@]}")" - # Only build the default Dockerfile if "default" is in the variant list - if [[ "${variants[*]}" =~ "default" ]] || [[ "${variants[*]}" =~ "onbuild" ]]; then - build "${version}" "" "${tag}" - fi - for variant in "${variants[@]}"; do # Skip non-docker directories [ -f "${version}/${variant}/Dockerfile" ] || continue + if [ "${variant}" = "onbuild" ]; then + build "${version}" "${default_variant}" "$tag" + fi + build "${version}" "${variant}" "${tag}" done diff --git a/update.sh b/update.sh index eff2004ae..65d1867c0 100755 --- a/update.sh +++ b/update.sh @@ -56,10 +56,15 @@ function update_node_version() { fromprefix="${arch}\\/" fi - sed -Ei -e 's/^FROM (.*)/FROM '"${fromprefix}"'\1/' "${dockerfile}" - sed -Ei -e 's/^(ENV NODE_VERSION |FROM .*node:).*/\1'"${version}.${fullVersion:-0}"'/' "${dockerfile}" + nodeVersion="${version}.${fullVersion:-0}" + + sed -Ei -e 's/^FROM (.*)/FROM '"$fromprefix"'\1/' "${dockerfile}" + sed -Ei -e 's/^(ENV NODE_VERSION ).*/\1'"${nodeVersion}"'/' "${dockerfile}" sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "${dockerfile}" + # Only for onbuild variant + sed -Ei -e 's/^(FROM .*node:)[^-]*(-.*)/\1'"${nodeVersion}"'\2/' "${dockerfile}" + # shellcheck disable=SC1004 new_line=' \\\ ' @@ -104,25 +109,24 @@ echo '#### DO NOT MODIFY. THIS FILE IS AUTOGENERATED #### ' | cat - travis.yml.template >.travis.yml for version in "${versions[@]}"; do - # Skip "docs" and other non-docker directories - [ -f "${version}/Dockerfile" ] || continue - parentpath=$(dirname "${version}") versionnum=$(basename "${version}") baseuri=$(get_config "${parentpath}" "baseuri") update=$(in_versions_to_update "${version}") - add_stage "${baseuri}" "${version}" "default" - - if [ "${update}" -eq 0 ]; then - info "Updating version ${version}..." - update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" & - fi - # Get supported variants according the target architecture # See details in function.sh IFS=' ' read -ra variants <<<"$(get_variants "${parentpath}")" + if [ -f "${version}/Dockerfile" ]; then + add_stage "${baseuri}" "${version}" "default" + + if [ "${update}" -eq 0 ]; then + info "Updating version ${version}..." + update_node_version "${baseuri}" "${versionnum}" "${parentpath}/Dockerfile.template" "${version}/Dockerfile" & + fi + fi + for variant in "${variants[@]}"; do # Skip non-docker directories [ -f "${version}/${variant}/Dockerfile" ] || continue