7 local rematch='^[^=]*=(.*)$'
8 if [[ $2 =~ $rematch ]]; then
9 read -r "$1" <<< "${BASH_REMATCH[1]}"
12 # There is no way to shift our callers args, so
13 # return 1 to indicate they should do it instead.
18 if type -p podman; then
21 # Docker is actually implemented by podman, and its OCI output
22 # is incompatible with some of the dockerd instances on GitLab
24 export BUILDAH_FORMAT=docker
25 elif getent group docker | grep -q "\b${USER}\b"; then
28 DOCKER_CMD="sudo docker"
49 --base|-b) read_arg base "$@" || shift;;
50 --base-version) read_arg base_version "$@" || shift;;
51 --no-login) no_login=1;;
52 *) echo -e "\\e[1;31mERROR\\e[0m: Unknown option '$1'"; exit 1;;
57 if [ $print_help == 1 ]; then
58 echo "$0 - Build and run Docker images"
60 echo "Usage: $0 <command> [options] [basename]"
62 echo "Available commands"
64 echo " build --base=<BASENAME> - Build Docker image <BASENAME>.Dockerfile"
65 echo " run --base=<BASENAME> - Run Docker image <BASENAME>"
66 echo " push --base=<BASENAME> - Push Docker image <BASENAME> to the registry"
67 echo " list - List available images"
68 echo " help - This help message"
75 if [ $list == 1 ]; then
76 echo "Available Docker images:"
77 for f in *.Dockerfile; do
78 filename=$( basename -- "$f" )
79 basename="${filename%.*}"
81 echo -e " \\e[1;39m$basename\\e[0m"
86 # All commands after this require --base to be set
87 if [ -z "${base}" ]; then
88 echo "Usage: $0 <command>"
92 if [ ! -f "$base.Dockerfile" ]; then
93 echo -e "\\e[1;31mERROR\\e[0m: Dockerfile for '$base' not found"
97 if [ -z "${base_version}" ]; then
100 base_version="v$base_version"
103 TAG="registry.gitlab.gnome.org/gnome/glib/${base}:${base_version}"
105 if [ $build == 1 ]; then
106 echo -e "\\e[1;32mBUILDING\\e[0m: ${base} as ${TAG}"
108 --build-arg HOST_USER_ID="$UID" \
109 --build-arg COVERITY_SCAN_PROJECT_NAME="${COVERITY_SCAN_PROJECT_NAME}" \
110 --build-arg COVERITY_SCAN_TOKEN="${COVERITY_SCAN_TOKEN}" \
112 --file "${base}.Dockerfile" .
116 if [ $push == 1 ]; then
117 echo -e "\\e[1;32mPUSHING\\e[0m: ${base} as ${TAG}"
119 if [ $no_login == 0 ]; then
120 $DOCKER_CMD login registry.gitlab.gnome.org
123 $DOCKER_CMD push $TAG
127 if [ $run == 1 ]; then
128 echo -e "\\e[1;32mRUNNING\\e[0m: ${base} as ${TAG}"
131 --volume "$(pwd)/..:/home/user/app" \
132 --workdir "/home/user/app" \
134 --interactive "${TAG}" \