-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.sh
More file actions
executable file
·31 lines (25 loc) · 1.35 KB
/
make.sh
File metadata and controls
executable file
·31 lines (25 loc) · 1.35 KB
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
#!/usr/bin/env bash
base=${1:-containers.intersystems.com/intersystems/iris-community:latest-preview}
tag=$(echo $base | cut -d':' -f2)
if [ -z "$2" ]; then
target=$(echo $base | rev | cut -d '/' -f 1 | rev | cut -d ':' -f1 )-light
else
target=${2}
fi
if [ ! -z "$3" ]; then
suffix=-${3}
fi
version=$(docker image inspect --format '{{index .Config.Labels "com.intersystems.platform-version"}}' $base | cut -d'.' -f1-2)
targets="--tag $target:$tag$suffix "
targets+="--tag $target:$version$suffix"
originalbase=$(docker history $base --format '{{.CreatedBy}}' --no-trunc | grep 'LABEL org.opencontainers.image.ref.name=' | cut -d'=' -f2 )
originalbase+=:$(docker history $base --format '{{.CreatedBy}}' --no-trunc | grep 'LABEL org.opencontainers.image.version=' | cut -d'=' -f2 )
labels=$(docker image inspect --format '{{range $k, $v := .Config.Labels}}--label {{$k}}="{{$v}}" {{end}}' $base)
eval "docker build ${labels} $targets --build-arg BASE_IMAGE=$base --build-arg ORIGINAL_BASE=$originalbase ."
export IMAGES=($target:$tag$suffix $target:$version$suffix)
export TAGS=($tag$suffix $version$suffix)
echo "Built images:"
echo 'ID Image Size' | awk -F' ' '{printf "%-12s %-70s %-10s\n", $1,$2,$3}'
for img in "${IMAGES[@]}"; do
docker images $img --format '{{.ID}} {{.Repository}}:{{.Tag}} {{.Size}}' | awk -F' ' '{printf "%-12s %-70s %-10s\n", $1,$2,$3}'
done