Skip to content

Commit

Permalink
WIP: ensure podman wrapper works from /home/tooling/
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Obuchowicz <[email protected]>
  • Loading branch information
AObuchow committed Sep 18, 2023
1 parent e3d3918 commit 4ce203b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion base/ubi8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ RUN \
chmod -R g=u /etc/passwd /etc/group /home && \
chmod +x /entrypoint.sh && \
# Create symbolic links from /home/tooling/ -> /home/user/
stow . -t /home/user/ -d /home/tooling/ --no-folding && \
stow . -t /home/user/ -d /home/tooling/ && \
# .viminfo cannot be a symbolic link for security reasons, so copy it to /home/user/
cp /home/tooling/.viminfo /home/user/.viminfo

Expand Down
10 changes: 6 additions & 4 deletions universal/ubi8/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# syntax=docker/dockerfile:1.3-labs

# updateBaseImages.sh can't operate on SHA-based tags as they're not date-based or semver-sequential, and therefore cannot be ordered
FROM quay.io/devfile/base-developer-image:ubi8-latest
#FROM quay.io/devfile/base-developer-image:ubi8-latest
FROM docker.io/library/udi-base
LABEL maintainer="Red Hat, Inc."

LABEL com.redhat.component="devfile-universal-container"
Expand Down Expand Up @@ -86,9 +87,10 @@ ENV KUBECONFIG=/home/tooling/.kube/config
USER 0

# Define user directory for binaries
RUN mkdir -p /home/user/.local/bin && \
RUN mkdir -p /home/tooling/.local/bin && \
chgrp -R 0 /home && chmod -R g=u /home
ENV PATH="/home/user/.local/bin:$PATH"
ENV PATH="/home/tooling/.local/bin:$PATH"

# Required packages for AWT
RUN dnf install -y libXext libXrender libXtst libXi
Expand Down Expand Up @@ -467,12 +469,12 @@ EOF
RUN echo 'export SDKMAN_DIR="/home/tooling/.sdkman"' >> /home/tooling/.bashrc
RUN echo '[[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]] && source "$SDKMAN_DIR/bin/sdkman-init.sh"' >> /home/tooling/.bashrc

# Set permissions on /etc/passwd and /home to allow arbitrary users to write
RUN chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home

# Create symbolic links from /home/tooling/ -> /home/user/
RUN stow . -t /home/user/ -d /home/tooling/ --no-folding

# Set permissions on /etc/passwd and /home to allow arbitrary users to write
RUN chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home

# cleanup dnf cache
RUN dnf -y clean all --enablerepo='*'
Expand Down
20 changes: 10 additions & 10 deletions universal/ubi8/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#!/bin/bash

# /home/user/ will be mounted to by a PVC if persistUserHome is enabled
if mountpoint -q /home/user/; then
# Create symbolic links from /home/tooling/ -> /home/user/
stow . -t /home/user/ -d /home/tooling/ --no-folding
# A symbolic link for .viminfo is not created for security reasons, so manually copy it
cp /home/tooling/.viminfo /home/user/.viminfo
fi

# Kubedock
if [ "${KUBEDOCK_ENABLED:-false}" = "true" ]; then
echo
Expand All @@ -34,7 +26,7 @@ if [ "${KUBEDOCK_ENABLED:-false}" = "true" ]; then

echo "Replacing podman with podman-wrapper..."

ln -f -s /usr/bin/podman.wrapper /home/user/.local/bin/podman
ln -f -s /usr/bin/podman.wrapper /home/tooling/.local/bin/podman

export TESTCONTAINERS_RYUK_DISABLED="true"
export TESTCONTAINERS_CHECKS_DISABLE="true"
Expand All @@ -46,7 +38,15 @@ else
echo "Kubedock is disabled. It can be enabled with the env variable \"KUBEDOCK_ENABLED=true\""
echo "set in the workspace Devfile or in a Kubernetes ConfigMap in the developer namespace."
echo
ln -f -s /usr/bin/podman.orig /home/user/.local/bin/podman
ln -f -s /usr/bin/podman.orig /home/tooling/.local/bin/podman
fi

# /home/user/ will be mounted to by a PVC if persistUserHome is enabled
if mountpoint -q /home/user/; then
# Create symbolic links from /home/tooling/ -> /home/user/
stow . -t /home/user/ -d /home/tooling/ --no-folding
# Vim does not permit .viminfo to be a symbolic link for security reasons, so manually copy it
cp /home/tooling/.viminfo /home/user/.viminfo
fi

exec "$@"

0 comments on commit 4ce203b

Please sign in to comment.