Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start-build-env.sh fix, added support of mac-os #7

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions start-build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}" - <<UserSpecificDocker
FROM beam-build
RUN rm -f /var/log/faillog /var/log/lastlog
Expand All @@ -82,11 +89,10 @@ RUN groupmod -g ${DOCKER_GROUP_ID} docker
RUN useradd -g ${GROUP_ID} -G docker -u ${USER_ID} -k /root -m ${USER_NAME} -d "${DOCKER_HOME_DIR}"
RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" > "/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 ""
Expand Down