Update service node image for new base
[integration/packaging.git] / docker / openstack / service / build_service.sh
1 #!/bin/bash
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}
7 if [ -n "$1" ] ; then
8     # use arg as image tag if supplied
9     IMAGE_TAG="$1"
10 fi
11 IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
12 DOCKERFILE=${DOCKERFILE:-"./build/Dockerfile"}
13
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
17
18 EXIT_CODE="$?"
19 if [ "$EXIT_CODE" = 0 ] ; then
20     PROXIES=""
21     if [ -n "$http_proxy" ] ; then
22         # noqa ShellCheckBear
23         PROXIES="--env http_proxy=$http_proxy --env https_proxy=$https_proxy --env no_proxy=$no_proxy"
24     fi
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"
29 else
30     echo "An error occurred during the build of $IMAGE_NAME"
31     exit $EXIT_CODE
32 fi
33