Skip to content

Commit

Permalink
feat: add bindfs to support linux users. Fixes cloudposse#594
Browse files Browse the repository at this point in the history
  • Loading branch information
drmikecrowe committed Feb 2, 2022
1 parent 8f987c7 commit 71a13b6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
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

0 comments on commit 71a13b6

Please sign in to comment.