-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·52 lines (47 loc) · 1.52 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
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
#
# To build without pushing to a registry, set DRY_RUN to anything other than
# the empty string. For example:
#
# DRY_RUN=1 ./build.sh
#
# To build and push images for just one Ruby version instead of all versions in
# versions/*, specify a version filename from versions/*. For example:
#
# ./build.sh 3_2
#
set -eu
# Build (and push, unless $DRY_RUN is non-empty) the base and builder images
# for the Ruby version defined in the file versions/$1.
build_version() {
RUBY_IS_PATCH=false
# shellcheck disable=SC1090
source "$1"
for IMAGE_TYPE in base builder; do
echo "Building ${IMAGE_TYPE} image for Ruby ${RUBY_MAJOR} (${RUBY_VERSION})"
IMAGE_NAME="publishing-platform-ruby-${IMAGE_TYPE}"
docker build . \
-t "ghcr.io/publishing-platform/${IMAGE_NAME}:${RUBY_MAJOR}" \
-f "${IMAGE_TYPE}.Dockerfile" \
--build-arg "RUBY_MAJOR=${RUBY_MAJOR}" \
--build-arg "RUBY_VERSION=${RUBY_VERSION}"
docker tag \
"ghcr.io/publishing-platform/${IMAGE_NAME}:${RUBY_MAJOR}" \
"ghcr.io/publishing-platform/${IMAGE_NAME}:${RUBY_VERSION}"
if [[ -n ${DRY_RUN:-} ]]; then
echo "dry run: not pushing image to registry"
else
if [[ "${RUBY_IS_PATCH}" != "true" ]]; then
docker push "ghcr.io/publishing-platform/${IMAGE_NAME}:${RUBY_MAJOR}"
fi
docker push "ghcr.io/publishing-platform/${IMAGE_NAME}:${RUBY_VERSION}"
fi
done
}
if [[ -n "${1:-}" ]]; then
build_version versions/"$1"
else
for v in versions/*; do
build_version "$v"
done
fi