1
0
Fork 0
mirror of https://github.com/docker-library/ruby.git synced 2022-11-09 11:41:34 -05:00

Add explicit "jessie" and "alpine3.4" aliases

This commit is contained in:
Tianon Gravi 2017-07-31 16:48:09 -07:00
parent 00ade5b52c
commit a6918175fd
18 changed files with 113 additions and 61 deletions

View file

@ -2,29 +2,38 @@ language: bash
services: docker
env:
- VERSION=2.4 VARIANT=
- VERSION=2.4 VARIANT=slim
- VERSION=2.4 VARIANT=alpine
- VERSION=2.3 VARIANT=
- VERSION=2.3 VARIANT=slim
- VERSION=2.3 VARIANT=alpine
- VERSION=2.2 VARIANT=
- VERSION=2.2 VARIANT=slim
- VERSION=2.2 VARIANT=alpine
- VERSION=2.4 VARIANT=jessie
- VERSION=2.4 VARIANT=jessie/slim
- VERSION=2.4 VARIANT=alpine3.4
- VERSION=2.3 VARIANT=jessie
- VERSION=2.3 VARIANT=jessie/slim
- VERSION=2.3 VARIANT=alpine3.4
- VERSION=2.2 VARIANT=jessie
- VERSION=2.2 VARIANT=jessie/slim
- VERSION=2.2 VARIANT=alpine3.4
install:
- git clone --depth 1 https://github.com/docker-library/official-images.git ~/official-images
before_script:
- env | sort
- cd "$VERSION"
- image="$(awk '$1 == "FROM" { print $2; exit }' onbuild/Dockerfile)${VARIANT:+-$VARIANT}"
- cd "$VERSION/$VARIANT"
- slash='/'; image="ruby:${VERSION}-${VARIANT//$slash/-}"
script:
- travis_retry docker build -t "$image" "${VARIANT:-.}"
- ~/official-images/test/run.sh "$image"
# the "onbuild" variant has to happen with the base variant because it's FROM it
- true && [ "$VARIANT" ] || travis_retry docker build -t "${image}-onbuild" onbuild
- |
(
set -Eeuo pipefail
set -x
travis_retry docker build -t "$image" .
~/official-images/test/run.sh "$image"
if [ -d onbuild ]; then
onbuildFrom="$(awk 'toupper($1) == "FROM" { print $2; exit }' onbuild/Dockerfile)"
docker tag "$image" "$onbuildFrom"
docker build -t "$image-onbuild" onbuild
~/official-images/test/run.sh "$image-onbuild"
fi
)
after_script:
- docker images

View file

@ -1,4 +1,4 @@
FROM alpine:3.4
FROM alpine:%%PLACEHOLDER%%
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \

View file

@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:%%PLACEHOLDER%%
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \

View file

@ -1,4 +1,4 @@
FROM debian:jessie
FROM debian:%%PLACEHOLDER%%
RUN apt-get update \
&& apt-get install -y --no-install-recommends \

View file

@ -1,16 +1,32 @@
#!/bin/bash
set -eu
#!/usr/bin/env bash
set -Eeuo pipefail
declare -A aliases=(
[2.4]='2 latest'
)
defaultDebianSuite='stretch'
declare -A debianSuites=(
[2.2]='jessie'
[2.3]='jessie'
[2.4]='jessie'
)
defaultAlpineVersion='3.6'
declare -A alpineVersions=(
[2.2]='3.4'
[2.3]='3.4'
[2.4]='3.4'
)
self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( */ )
versions=( "${versions[@]%/}" )
# sort version numbers with highest first
IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -rV) ); unset IFS
# get the most recent commit which modified any of "$@"
fileCommit() {
git log -1 --format='format:%H' HEAD -- "$@"
@ -37,7 +53,7 @@ getArches() {
local repo="$1"; shift
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
eval "declare -A -g parentRepoToArches=( $(
eval "declare -g -A parentRepoToArches=( $(
find -name 'Dockerfile' -exec awk '
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
print "'"$officialImagesUrl"'" $2
@ -65,39 +81,47 @@ join() {
}
for version in "${versions[@]}"; do
commit="$(dirCommit "$version")"
debianSuite="${debianSuites[$version]:-$defaultDebianSuite}"
alpineVersion="${alpineVersions[$version]:-$defaultAlpineVersion}"
parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
arches="${parentRepoToArches[$parent]}"
for v in \
{stretch,jessie}{,/slim,/onbuild} \
alpine{3.6,3.4} \
; do
dir="$version/$v"
variant="$(basename "$v")"
fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "RUBY_VERSION" { print $3; exit }')"
[ -f "$dir/Dockerfile" ] || continue
versionAliases=(
$fullVersion
$version
${aliases[$version]:-}
)
commit="$(dirCommit "$dir")"
echo
cat <<-EOE
Tags: $(join ', ' "${versionAliases[@]}")
Architectures: $(join ', ' $arches)
GitCommit: $commit
Directory: $version
EOE
versionDockerfile="$dir/Dockerfile"
if [ "$variant" = 'onbuild' ]; then
versionDockerfile="$(dirname "$dir")/Dockerfile"
fi
fullVersion="$(git show "$commit":"$versionDockerfile" | awk '$1 == "ENV" && $2 == "RUBY_VERSION" { print $3; exit }')"
for variant in slim alpine onbuild; do
[ -f "$version/$variant/Dockerfile" ] || continue
commit="$(dirCommit "$version/$variant")"
versionAliases=(
$fullVersion
$version
${aliases[$version]:-}
)
variantAliases=( "${versionAliases[@]/%/-$variant}" )
if [ "$variant" = "$debianSuite" ]; then
variantAliases+=( "${versionAliases[@]}" )
elif [ "$variant" = "alpine${alpineVersion}" ]; then
variantAliases+=( "${versionAliases[@]/%/-alpine}" )
fi
variantAliases=( "${variantAliases[@]//latest-/}" )
case "$variant" in
onbuild) variantArches="$arches" ;;
case "$v" in
*/onbuild)
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$(dirname "$dir")/Dockerfile")"
variantArches="${parentRepoToArches[$variantParent]}"
;;
*)
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")"
variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$dir/Dockerfile")"
variantArches="${parentRepoToArches[$variantParent]}"
;;
esac
@ -107,7 +131,7 @@ for version in "${versions[@]}"; do
Tags: $(join ', ' "${variantAliases[@]}")
Architectures: $(join ', ' $variantArches)
GitCommit: $commit
Directory: $version/$variant
Directory: $dir
EOE
done
done

View file

@ -1,5 +1,5 @@
#!/bin/bash
set -eo pipefail
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
@ -24,7 +24,7 @@ for version in "${versions[@]}"; do
if [ "$rcVersion" != "$version" ]; then
rcGrepV=
fi
IFS=$'\n'; allVersions=(
$(curl -fsSL --compressed "https://cache.ruby-lang.org/pub/ruby/$rcVersion/" \
| grep -E '<a href="ruby-'"$rcVersion"'.[^"]+\.tar\.xz' \
@ -48,20 +48,39 @@ for version in "${versions[@]}"; do
versionReleasePage="$(echo "$releasePage" | grep "<td>Ruby $fullVersion</td>" -A 2 | awk -F '"' '$1 == "<td><a href=" { print $2; exit }')"
shaVal="$(curl -fsSL "https://www.ruby-lang.org/$versionReleasePage" |tac|tac| grep "ruby-$fullVersion.tar.xz" -A 5 | awk '/^SHA256:/ { print $2; exit }')"
sedStr="
s!%%VERSION%%!$version!g;
s!%%FULL_VERSION%%!$fullVersion!g;
s!%%SHA256%%!$shaVal!g;
s!%%RUBYGEMS%%!$rubygems!g;
s!%%BUNDLER%%!$bundler!g;
"
echo "$version: $fullVersion; rubygems $rubygems, bundler $bundler; $shaVal"
for variant in alpine slim onbuild ''; do
[ -d "$version/$variant" ] || continue
sed -r "$sedStr" "Dockerfile${variant:+-$variant}.template" > "$version/$variant/Dockerfile"
if [ "$variant" != 'onbuild' ]; then
travisEnv='\n - VERSION='"$version VARIANT=$variant$travisEnv"
fi
for v in \
alpine{3.4,3.6} \
{jessie,stretch}{/slim,/onbuild,} \
; do
dir="$version/$v"
variant="$(basename "$v")"
[ -d "$dir" ] || continue
case "$variant" in
slim|onbuild|windowsservercore) template="$variant"; tag="$(basename "$(dirname "$dir")")" ;;
alpine*) template='alpine'; tag="${variant#alpine}" ;;
*) template='debian'; tag="$variant" ;;
esac
template="Dockerfile-${template}.template"
sed -r \
-e 's!%%VERSION%%!'"$version"'!g' \
-e 's!%%FULL_VERSION%%!'"$fullVersion"'!g' \
-e 's!%%SHA256%%!'"$shaVal"'!g' \
-e 's!%%RUBYGEMS%%!'"$rubygems"'!g' \
-e 's!%%BUNDLER%%!'"$bundler"'!g' \
-e 's/^(FROM (debian|buildpack-deps|alpine)):.*/\1:'"$tag"'/' \
"$template" > "$dir/Dockerfile"
case "$v" in
*/onbuild) ;;
*)
travisEnv='\n - VERSION='"$version VARIANT=$v$travisEnv"
;;
esac
done
done