-
Notifications
You must be signed in to change notification settings - Fork 30
/
build-environment-image
executable file
·65 lines (56 loc) · 1.36 KB
/
build-environment-image
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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
SELFDIR=$(dirname "$0")
SELFDIR=$(cd "$SELFDIR" && pwd)
# shellcheck source=lib/library.sh
source "$SELFDIR/lib/library.sh"
function usage()
{
echo "Usage: ./build-environment [OPTIONS] <ENV>"
echo "Build a build environment Docker image. A build environment is an image based on"
echo "a certain Linux distro, and is used to compile Ruby for that distro."
echo
echo "<ENV> is the name of a subdirectory in environments/, such as 'ubuntu-22.04'."
echo
echo "This script will produce a Docker image called"
echo "'ghcr.io/fullstaq-ruby/server-edition-ci-images:<ENV>-v<VERSION>'."
echo
echo "Optional options:"
echo " -h Show usage"
}
function parse_options()
{
local OPTIND=1
local ORIG_ARGV
local opt
while getopts "f:h" opt; do
case "$opt" in
f)
FORMAT="$OPTARG"
;;
h)
usage
exit
;;
*)
return 1
;;
esac
done
(( OPTIND -= 1 )) || true
shift $OPTIND || true
ORIG_ARGV=("$@")
if [[ $# -ne 1 ]]; then
usage
exit 1
fi
}
parse_options "$@"
ENV="$1"
IMAGE_NAME=ghcr.io/fullstaq-ruby/server-edition-ci-images
IMAGE_VERSION=$(read_single_value_file "$SELFDIR/environments/$ENV/image_tag")
if [[ ! -e "$SELFDIR/environments/$ENV" ]]; then
echo "ERROR: $SELFDIR/environments/$ENV does not exist." >&2
exit 1
fi
run docker build --pull -t "$IMAGE_NAME:$ENV-v$IMAGE_VERSION" "$SELFDIR/environments/$ENV"