2 # file: build_service.sh
3 # info: builds a docker service image
4 IMAGE_REGISTRY=${IMAGE_REGISTRY:-odl-registry:4000}
5 IMAGE_REPO=${IMAGE_REPO:-s3p/service}
6 IMAGE_TAG=${IMAGE_TAG:-latest}
8 # use arg as image tag if supplied
11 IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
12 DOCKERFILE=${DOCKERFILE:-"./build/Dockerfile"}
14 echo "Building $IMAGE_NAME from Dockerfile=$DOCKERFILE at $(date) ... "
15 # shellcheck disable=SC2154
16 docker build -t ${IMAGE_NAME} -f ${DOCKERFILE} --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy ./build
19 if [ "$EXIT_CODE" = 0 ] ; then
21 if [ -n "$http_proxy" ] ; then
23 PROXIES="--env http_proxy=$http_proxy --env https_proxy=$https_proxy --env no_proxy=$no_proxy"
25 echo "Docker image $IMAGE_NAME built successfully."
26 docker images $IMAGE_NAME
27 echo "You can launch it with the following example command:"
28 echo " docker run -it --rm $PROXIES $IMAGE_NAME bash"
30 echo "An error occurred during the build of $IMAGE_NAME"