diff --git a/start-build-env.sh b/start-build-env.sh index 52cebe45455fd..a6456e71cb7d3 100755 --- a/start-build-env.sh +++ b/start-build-env.sh @@ -37,9 +37,18 @@ USER_ID=$(id -u "${USER_NAME}") if [ "$(uname -s)" = "Darwin" ]; then GROUP_ID=100 + if (dscl . -read /Groups/docker); then + DOCKER_GROUP_ID=$(dscl . -read /Groups/docker| awk '($1 == "PrimaryGroupID:") { print $2 }') + else + # if Docker post-install steps to manage as non-root user not performed - will use dummy gid + DOCKER_GROUP_ID=1000 + echo "`tput setaf 3`Please take a look post-install steps, to manage Docker as non-root user" + echo "`tput setaf 2`https://docs.docker.com/engine/install/linux-postinstall" + fi fi if [ "$(uname -s)" = "Linux" ]; then + DOCKER_GROUP_ID=$(getent group docker | cut -d':' -f3) GROUP_ID=$(id -g "${USER_NAME}") # man docker-run # When using SELinux, mounted directories may not be accessible @@ -72,8 +81,6 @@ fi # Set the home directory in the Docker container. DOCKER_HOME_DIR=${DOCKER_HOME_DIR:-/home/${USER_NAME}} -DOCKER_GROUP_ID=$(getent group docker | cut -d':' -f3) - docker build -t "beam-build-${USER_ID}" - < "/etc/sudoers.d/beam-build-${USER_ID}" ENV HOME "${DOCKER_HOME_DIR}" -ENV GOPATH ${HOME}/beam/sdks/go/examples/.gogradle/project_gopath - +ENV GOPATH ${DOCKER_HOME_DIR}/beam/sdks/go/examples/.gogradle/project_gopath # This next command still runs as root causing the ~/.cache/go-build to be owned by root RUN go get github.com/linkedin/goavro -RUN chown -R ${USER_NAME}:${GROUP_ID} ${HOME}/.cache +RUN chown -R ${USER_NAME}:${GROUP_ID} ${DOCKER_HOME_DIR}/.cache UserSpecificDocker echo ""