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.
19 if docker -v |& grep -q podman; then
22 # Docker is actually implemented by podman, and its OCI output
23 # is incompatible with some of the dockerd instances on GitLab
25 export BUILDAH_FORMAT=docker
46 --base|-b) read_arg base "$@" || shift;;
47 --base-version) read_arg base_version "$@" || shift;;
48 --no-login) no_login=1;;
49 *) echo -e "\\e[1;31mERROR\\e[0m: Unknown option '$1'"; exit 1;;
54 if [ $print_help == 1 ]; then
55 echo "$0 - Build and run Docker images"
57 echo "Usage: $0 <command> [options] [basename]"
59 echo "Available commands"
61 echo " build --base=<BASENAME> - Build Docker image <BASENAME>.Dockerfile"
62 echo " run --base=<BASENAME> - Run Docker image <BASENAME>"
63 echo " push --base=<BASENAME> - Push Docker image <BASENAME> to the registry"
64 echo " list - List available images"
65 echo " help - This help message"
72 if [ $list == 1 ]; then
73 echo "Available Docker images:"
74 for f in *.Dockerfile; do
75 filename=$( basename -- "$f" )
76 basename="${filename%.*}"
78 echo -e " \\e[1;39m$basename\\e[0m"
83 # All commands after this require --base to be set
84 if [ -z "${base}" ]; then
85 echo "Usage: $0 <command>"
86 echo "Or use \"$0 help\" for a list of commands"
90 if [ ! -f "$base.Dockerfile" ]; then
91 echo -e "\\e[1;31mERROR\\e[0m: Dockerfile for '$base' not found"
95 if [ -z "${base_version}" ]; then
98 base_version="v$base_version"
101 TAG="registry.gitlab.gnome.org/gnome/at-spi2-core/${base}:${base_version}"
103 if [ $build == 1 ]; then
104 echo -e "\\e[1;32mBUILDING\\e[0m: ${base} as ${TAG}"
105 $SUDO_CMD docker build \
107 --file "${base}.Dockerfile" .
111 if [ $push == 1 ]; then
112 echo -e "\\e[1;32mPUSHING\\e[0m: ${base} as ${TAG}"
114 if [ $no_login == 0 ]; then
115 $SUDO_CMD docker login registry.gitlab.gnome.org
118 $SUDO_CMD docker push $TAG
122 if [ $run == 1 ]; then
123 echo -e "\\e[1;32mRUNNING\\e[0m: ${base} as ${TAG}"
124 $SUDO_CMD docker run \
126 --volume "$(pwd)/..:/home/user/app" \
127 --workdir "/home/user/app" \
129 --interactive "${TAG}" \