aboutsummaryrefslogtreecommitdiffstats
path: root/docker/rebuild_osmocom_jenkins_image.sh
blob: c4e3b10ea467d79402331ea0051b06f813bc14e9 (plain)
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
#!/bin/bash -e

# Executes docker build with the given parameters and retry in case of error.
function build_once() {
	# In case the debian apt archive has become out of sync, try a
	# --no-cache build if it fails.

	# shellcheck disable=SC2068
	docker build $@ -f Dockerfile_osmocom_jenkins.amd64 . \
	|| docker build --no-cache $@ -f Dockerfile_osmocom_jenkins.amd64 .
}

# Builds a container with a debian version and tag name as parameter.
function build_container() {
	local tag_name=${1}
	local debian_version=${2}

	echo "Pulling ${debian_version} image"
	docker pull "debian:${debian_version}"

	echo "Building for ${debian_version} and setting tag ${tag_name}"
	build_once "-t" "${tag_name}" "--build-arg" DEBIAN_VERSION="${debian_version}"
}

# Create containers using jessie (Debian 8.0) and stretch (Debian 9.0) as base.
build_container osmocom:amd64 jessie
build_container osmocom:deb9_amd64 stretch