Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 1 addition & 6 deletions containers/base/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ ENV SHELL_CONFIG_DIR="$VOLS_DIR/shell"
RUN mkdir -m 755 $SHELL_CONFIG_DIR \
&& chown $DEV_USER_UID:$DEV_USER_GID $SHELL_CONFIG_DIR

# Setup Bash history
RUN BASH_CONFIG_DIR=$SHELL_CONFIG_DIR/bash \
&& sudo -u $DEV_USER mkdir -m 755 $BASH_CONFIG_DIR \
&& sudo -u $DEV_USER touch $BASH_CONFIG_DIR/bash_history \
&& sudo -u $DEV_USER ln -s $BASH_CONFIG_DIR/bash_history $DEV_USER_HOME/.bash_history

# Modify PS1 to put a * after the hostname. This is sort of useful because it
# let's you quickly see if you are inside the container or not.
RUN sed -i 's;PS1.*\\h;&*;' /root/.bashrc $DEV_USER_HOME/.bashrc
Expand All @@ -184,6 +178,7 @@ RUN mkdir -m 755 $ENTRYPOINT_DIR
COPY entrypoint.sh /entrypoint.sh
COPY fix_user.sh $ENTRYPOINT_DIR/00_fix_user.sh
COPY login_shim.sh $ENTRYPOINT_DIR/01_login_shim.sh
COPY shell_init.sh $ENTRYPOINT_DIR/04_shell_init.sh

# Add ~/.bashrc.d support to the user's ~/.bashrc
COPY bashrcd_fragment.bash /tmp/bashrcd_fragment.bash
Expand Down
30 changes: 30 additions & 0 deletions containers/base/shell_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Copyright (c) 2026 Tim Perkins

set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'

# This should never happen, but check anyway
if [ -z "${SHELL_CONFIG_DIR:-}" ]; then
echo "ERROR: Essential shell variable is not defined!" >&2
exit 1
fi

is_empty_dir() {
find "$1" -maxdepth 0 -type d -empty | grep -q .
}

bash_config_dir=$SHELL_CONFIG_DIR/bash

if is_empty_dir $SHELL_CONFIG_DIR; then
mkdir -m 700 $bash_config_dir
touch $bash_config_dir/bash_history
fi

# Always create the symlink in the home directory
ln -s $bash_config_dir/bash_history $HOME/.bash_history

exec "$@"
19 changes: 4 additions & 15 deletions containers/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ IFS=$'\n\t'
IMAGE_REPO="ghcr.io/taughz/dev"
DEFAULT_TARGET_TAG="main"

# The names of the volumes
SHELL_CONFIG_VOL="shell-config"

# The default projects directory
DEFAULT_PROJECTS_DIR="$HOME/Projects"

Expand Down Expand Up @@ -138,15 +135,6 @@ SHELL_CONFIG_DIR=$(get_from_env "$IMAGE_ENV" "SHELL_CONFIG_DIR")
EMACS_CONFIG_DIR=$(get_from_env "$IMAGE_ENV" "EMACS_CONFIG_DIR" || true)
DOOM_CONFIG_DIR=$(get_from_env "$IMAGE_ENV" "DOOM_CONFIG_DIR" || true)

# Check for volumes, create them if necessary
vols=($SHELL_CONFIG_VOL)
for vol in "${vols[@]}"; do
if ! docker volume ls -q | grep -q $vol; then
echo "Creating volume: $vol" >&2
docker volume create $vol > /dev/null
fi
done

# Ensure the files and directories we expect exist
ensure_exists f 600 $HOME/.Xauthority
ensure_exists d 700 $HOME/.ssh
Expand All @@ -156,6 +144,7 @@ ensure_exists d 700 $HOME/.xpra
ensure_exists f 600 $HOME/.claude.json
ensure_exists d 700 $HOME/.claude
ensure_exists d 700 $HOME/.taughz
ensure_exists d 700 $HOME/.taughz/shell
ensure_exists d 700 $HOME/.taughz/emacs.d
ensure_exists d 700 $HOME/.taughz/doom.d

Expand Down Expand Up @@ -210,7 +199,7 @@ CLAUDE_FLAGS=(
)

SHELL_FLAGS=(
--mount "type=volume,src=$SHELL_CONFIG_VOL,dst=$SHELL_CONFIG_DIR"
--mount "type=bind,src=$HOME/.taughz/shell,dst=$SHELL_CONFIG_DIR"
)

emacs_flags=()
Expand All @@ -232,8 +221,8 @@ if [ $use_tz -ne 0 ]; then
fi

echo_cmd docker run --rm --tty --interactive --privileged --network=host --env "TERM=$TERM" \
"${DISPLAY_FLAGS[@]}" "${SSH_FLAGS[@]}" "${GPG_FLAGS[@]}" "${GIT_FLAGS[@]}" \
"${XPRA_FLAGS[@]}" "${CLAUDE_FLAGS[@]}" "${SHELL_FLAGS[@]}" "${fixed_user_flags[@]}" \
"${fixed_user_flags[@]}" "${DISPLAY_FLAGS[@]}" "${SSH_FLAGS[@]}" "${GPG_FLAGS[@]}" \
"${GIT_FLAGS[@]}" "${XPRA_FLAGS[@]}" "${CLAUDE_FLAGS[@]}" "${SHELL_FLAGS[@]}" \
"${emacs_flags[@]}" "${projects_flags[@]}" "${tz_flags[@]}" "$TARGET_IMAGE"

exit 0