pegleg/tools/pegleg.sh
Pete Birley 168c4aa3c8 Docker: use host network for build and none for running pegleg
This PS updates the pegleg script to build and run the docker
image/container with host networking/no networking - enabling it
to be used seamlessly on k8s hosts that do not make use of dockers
iptables rules.

Change-Id: Ia08b805f79ec8f82f3555856f316921f7eddb064
2018-03-02 20:46:51 -05:00

30 lines
764 B
Bash
Executable File

#!/usr/bin/env bash
set -e
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
SCRIPT_DIR=$(realpath "$(dirname "${0}")")
SOURCE_DIR=${SCRIPT_DIR}/pegleg
if [ -d "$PWD/global" ]; then
WORKSPACE="$PWD"
else
WORKSPACE=$(realpath "${SCRIPT_DIR}/..")
fi
IMAGE_PEGLEG=${IMAGE_PEGLEG:-quay.io/attcomdev/pegleg:latest}
if [[ -z ${http_proxy} && -z ${https_proxy} ]]
then
docker build --network=host -q --rm -t "${IMAGE_PEGLEG}" "${SOURCE_DIR}" > /dev/null
else
docker build --network=host -q --rm -t "${IMAGE_PEGLEG}" --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} "${SOURCE_DIR}" > /dev/null
fi
docker run --net=none --rm -t \
-v "${WORKSPACE}:/var/pegleg" \
"${IMAGE_PEGLEG}" \
pegleg "${@}"