Fix builds on selinux systems

This commit is contained in:
derekwaynecarr 2016-05-20 11:39:40 -04:00
parent 2c471bce4e
commit 3b93d4dac1

View File

@ -308,8 +308,10 @@ function kube::build::clean_output() {
# Make sure the _output directory is created and mountable by docker
function kube::build::prepare_output() {
# See auto-creation of host mounts: https://github.com/docker/docker/pull/21666
# if selinux is enabled, docker run -v /foo:/foo:Z will not autocreate the host dir
mkdir -p "${LOCAL_OUTPUT_SUBPATH}"
mkdir -p "${LOCAL_OUTPUT_BINPATH}"
# On RHEL/Fedora SELinux is enabled by default and currently breaks docker
# volume mounts. We can work around this by explicitly adding a security
# context to the _output directory.
@ -327,8 +329,11 @@ function kube::build::prepare_output() {
number=${#DOCKER_MOUNT_ARGS[@]}
for (( i=0; i<number; i++ )); do
if [[ "${DOCKER_MOUNT_ARGS[i]}" =~ "${KUBE_ROOT}" ]]; then
## Ensure we don't label the argument multiple times
if [[ ! "${DOCKER_MOUNT_ARGS[i]}" == *:Z ]]; then
DOCKER_MOUNT_ARGS[i]="${DOCKER_MOUNT_ARGS[i]}:Z"
fi
fi
done
fi