-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·42 lines (37 loc) · 1.38 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
set -e
oracle_versions=( vendor/* )
logfile="log/build-$(date "+%Y%m%d%H%M%S").log"
touch "$logfile"
tag_prefix="tobiashm/ruby-instantclient"
while read -r ruby_version; do
actual_ruby_version=$(docker run --rm "ruby:$ruby_version-slim" ruby -e "puts RUBY_VERSION")
for oracle_version in "${oracle_versions[@]#vendor/}"; do
version="$ruby_version-$oracle_version"
for variant in basic basiclite; do
tag="$tag_prefix:$version-$variant"
actual_ruby_version_tag="$tag_prefix:$actual_ruby_version-$oracle_version-$variant"
if [ $(docker image ls $actual_ruby_version_tag --format="true") ]; then
echo "Skipping $version-$variant because it has already been build!"
continue
fi
echo "Building $version-$variant ..."
docker buildx build --load \
--platform linux/amd64 \
-f "Dockerfile-$version-$variant" \
-t "$tag" \
-t "$actual_ruby_version_tag" . >> "$logfile" 2>&1
if [ "$PUSH" ]; then
docker push "$tag" >> "$logfile" 2>&1
docker push "$actual_ruby_version_tag" >> "$logfile" 2>&1
fi
if [ "$variant" == "basiclite" ]; then
default_tag="${tag%-$variant}"
docker tag "$tag" "$default_tag" >> "$logfile" 2>&1
if [ "$PUSH" ]; then
docker push "$default_tag" >> "$logfile" 2>&1
fi
fi
done
done
done < ruby-versions