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

feat: add bindfs to support linux users. Fixes #594 #769

Merged
merged 3 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion os/debian/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ COPY packages.txt os/debian/packages-debian.txt /etc/apt/
## Here is where we would copy in the repo checksum in an attempt to ensure updates bust the Docker build cache

# Add CloudPosse package repo
RUN apt-get update && apt-get install -y apt-utils && apt-get install -y curl
RUN apt-get update && apt-get install -y apt-utils && apt-get install -y curl bindfs
RUN curl -1sLf 'https://dl.cloudsmith.io/public/cloudposse/packages/cfg/setup/bash.deb.sh' | bash

# Install Google package repo
Expand Down
10 changes: 10 additions & 0 deletions rootfs/etc/profile.d/_localhost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if [[ -n $GEODESIC_HOST_UID ]] && [[ -n $GEODESIC_HOST_GID ]] && df -a | grep -q /localhost.bindfs; then
# Things are really wonky if this fails -- i think 'set -e' is good here
set -e
if [ -d /localhost ]; then
mv /localhost /localhost.from-docker
mkdir /localhost
fi
bindfs --create-for-user="$GEODESIC_HOST_UID" --create-for-group="$GEODESIC_HOST_GID" /localhost.bindfs /localhost
fi
cd $GEODESIC_WORKDIR
14 changes: 9 additions & 5 deletions rootfs/templates/wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ function use() {
DOCKER_ARGS=()
fi

if [ "${OS}" == 'Linux' ]; then
DOCKER_ARGS+=(--env GEODESIC_HOST_UID="$(id -u)" --env GEODESIC_HOST_GID="$(id -g)")
fi

if [ "${WITH_DOCKER}" == "true" ]; then
# Bind-mount docker socket into container
# Should work on Linux and Mac.
Expand Down Expand Up @@ -155,11 +159,11 @@ function use() {
if [ "${local_home}" == "/localhost" ]; then
echo "WARNING: not mounting ${local_home} because it conflicts with geodesic"
else
echo "# Mounting ${local_home} into container with workdir ${GEODESIC_HOST_CWD}"
DOCKER_ARGS+=(
--volume="${local_home}:/localhost"
--env LOCAL_HOME="${local_home}"
)
LOCALHOST="localhost"
[ "${OS}" == 'Linux' ] && LOCALHOST="localhost.bindfs"
echo "# Mounting ${local_home} into container"
DOCKER_ARGS+=(--volume=${local_home}:/$LOCALHOST)
DOCKER_ARGS+=(--env LOCAL_HOME=${local_home})
fi

DOCKER_ARGS+=(
Expand Down