From 4f6f450eb1ee6afad37c50fe92fed129cab99aa2 Mon Sep 17 00:00:00 2001 From: Tim Perkins Date: Fri, 31 Jul 2026 16:14:59 -0400 Subject: [PATCH] Put Bash config into directories --- containers/base/Containerfile | 18 +++++++----------- containers/base/bashrc.d/gpg_setup.bash | 7 +++++++ containers/emacs/Containerfile | 14 +++----------- containers/emacs/bashrc.d/emacs_setup.bash | 9 +++++++++ containers/python/Containerfile | 11 +++-------- containers/ros/Containerfile | 15 ++++----------- .../ros_setup.bash} | 4 ++++ 7 files changed, 37 insertions(+), 41 deletions(-) create mode 100644 containers/base/bashrc.d/gpg_setup.bash create mode 100644 containers/emacs/bashrc.d/emacs_setup.bash rename containers/ros/{bashrc_ros.bash => bashrc.d/ros_setup.bash} (70%) diff --git a/containers/base/Containerfile b/containers/base/Containerfile index 9952e4f..ee43bd5 100644 --- a/containers/base/Containerfile +++ b/containers/base/Containerfile @@ -163,27 +163,23 @@ RUN mkdir -m 755 $SHELL_CONFIG_DIR \ # 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 -# Enable GPG agent by adding GPG_TTY -RUN { \ - echo; \ - echo "# Set this for gpg-agent"; \ - echo "export GPG_TTY=\$(tty)"; \ - } >> $DEV_USER_HOME/.bashrc - # Create directory for entry point scripts ENV ENTRYPOINT_DIR="/etc/entrypoint.d" RUN mkdir -m 755 $ENTRYPOINT_DIR +# Add ~/.bashrc.d support to the user's ~/.bashrc +COPY bashrcd_fragment.bash /tmp/bashrcd_fragment.bash +RUN cat /tmp/bashrcd_fragment.bash >> $DEV_USER_HOME/.bashrc \ + && sudo -u $DEV_USER mkdir -m 755 $DEV_USER_HOME/.bashrc.d + # Copy the entry point script, login shim, etc COPY entrypoint.sh /entrypoint.sh COPY entrypoint.d/fix_user.sh $ENTRYPOINT_DIR/10_fix_user.sh COPY entrypoint.d/login_shim.sh $ENTRYPOINT_DIR/11_login_shim.sh COPY entrypoint.d/shell_init.sh $ENTRYPOINT_DIR/14_shell_init.sh -# Add ~/.bashrc.d support to the user's ~/.bashrc -COPY bashrcd_fragment.bash /tmp/bashrcd_fragment.bash -RUN cat /tmp/bashrcd_fragment.bash >> $DEV_USER_HOME/.bashrc \ - && sudo -u $DEV_USER mkdir -m 755 $DEV_USER_HOME/.bashrc.d +# Copy the GPG setup, etc +COPY --chown=$DEV_USER bashrc.d/gpg_setup.bash $DEV_USER_HOME/.bashrc.d/10_gpg_setup.bash # Here we set the entry point to the main entry point script. This script in # turn execs a chain of other entry points. This allows other images to layer diff --git a/containers/base/bashrc.d/gpg_setup.bash b/containers/base/bashrc.d/gpg_setup.bash new file mode 100644 index 0000000..30fdff2 --- /dev/null +++ b/containers/base/bashrc.d/gpg_setup.bash @@ -0,0 +1,7 @@ +# Copyright (c) 2026 Tim Perkins + +# NOTE This script is expected to be sourced! + +# Set this for gpg-agent +export GPG_TTY +GPG_TTY=$(tty) diff --git a/containers/emacs/Containerfile b/containers/emacs/Containerfile index 01e8aca..924667f 100644 --- a/containers/emacs/Containerfile +++ b/containers/emacs/Containerfile @@ -113,20 +113,12 @@ RUN mkdir -p $(dirname $DE_NERDFONT_FILE) \ && curl -fL -o $DE_NERDFONT_FILE "$DE_NERDFONT_URL" \ && fc-cache -f -# Add VTerm integration to Bash config -RUN { \ - echo; \ - echo "# When using VTerm, include the Bash integration"; \ - echo "if [ \"\${INSIDE_EMACS}\" = \"vterm\" \\"; \ - echo " -a -n \"\${EMACS_VTERM_PATH}\" \\"; \ - echo " -a -f \"\${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh\" ]; then"; \ - echo " source \"\${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh\""; \ - echo "fi"; \ - } >> $DEV_USER_HOME/.bashrc - # Copy entry point for config initialization COPY entrypoint.d/emacs_init.sh $ENTRYPOINT_DIR/80_emacs_init.sh +# Add VTerm integration to Bash config +COPY --chown=$DEV_USER bashrc.d/emacs_setup.bash $DEV_USER_HOME/.bashrc.d/80_emacs_setup.bash + # Persistent storage for the Emacs and Doom config directories. These # directories will be initialized with the Doom files from above. VOLUME ["$EMACS_CONFIG_DIR", "$DOOM_CONFIG_DIR"] diff --git a/containers/emacs/bashrc.d/emacs_setup.bash b/containers/emacs/bashrc.d/emacs_setup.bash new file mode 100644 index 0000000..f75826d --- /dev/null +++ b/containers/emacs/bashrc.d/emacs_setup.bash @@ -0,0 +1,9 @@ +# Copyright (c) 2026 Tim Perkins + +# NOTE This script is expected to be sourced! + +# When using VTerm, include the Bash integration +if [ "${INSIDE_EMACS}" = "vterm" -a -n "${EMACS_VTERM_PATH}" \ + -a -f "${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh" ]; then + source "${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh" +fi diff --git a/containers/python/Containerfile b/containers/python/Containerfile index 5232004..5a8b53b 100644 --- a/containers/python/Containerfile +++ b/containers/python/Containerfile @@ -54,14 +54,9 @@ RUN pipx install --global \ tox \ uv -# Enable Poetry autocompletion -RUN poetry completions bash > $DEV_USER_HOME/.bashrc_poetry \ - && { \ - echo; \ - echo "# Source Poetry autocompletion"; \ - echo "source \"\$HOME/.bashrc_poetry\""; \ - } >> $DEV_USER_HOME/.bashrc - # Switch to non-root user USER $DEV_USER WORKDIR $DEV_USER_HOME + +# Enable Poetry autocompletion +RUN poetry completions bash > $DEV_USER_HOME/.bashrc.d/21_python_poetry_completions.bash diff --git a/containers/ros/Containerfile b/containers/ros/Containerfile index bb5b5d1..35e20b4 100644 --- a/containers/ros/Containerfile +++ b/containers/ros/Containerfile @@ -59,9 +59,6 @@ RUN apt-get update \ # Bootstrap Rosdep RUN rosdep init -# Copy the ROS entry point -COPY entrypoint.d/ros_entrypoint.sh $ENTRYPOINT_DIR/20_ros_entrypoint.sh - # Switch to non-root user USER $DEV_USER WORKDIR $DEV_USER_HOME @@ -75,12 +72,8 @@ RUN colcon --log-base /dev/null mixin add default "$COLCON_MIXIN_URL" \ && colcon --log-base /dev/null metadata add default "$COLCON_METADATA_URL" \ && colcon --log-base /dev/null metadata update -# Copy the extra bashrc for completion, etc -COPY bashrc_ros.bash $DEV_USER_HOME/.bashrc_ros +# Copy the ROS entry point +COPY entrypoint.d/ros_entrypoint.sh $ENTRYPOINT_DIR/20_ros_entrypoint.sh -# Enable ROS autocompletion -RUN { \ - echo; \ - echo "# Source extra ROS shell helpers"; \ - echo "source \"\$HOME/.bashrc_ros\""; \ - } >> $DEV_USER_HOME/.bashrc +# Copy the ROS setup for autocompletion, etc +COPY --chown=$DEV_USER bashrc.d/ros_setup.bash $DEV_USER_HOME/.bashrc.d/22_ros_setup.bash diff --git a/containers/ros/bashrc_ros.bash b/containers/ros/bashrc.d/ros_setup.bash similarity index 70% rename from containers/ros/bashrc_ros.bash rename to containers/ros/bashrc.d/ros_setup.bash index 7571b40..8616c23 100644 --- a/containers/ros/bashrc_ros.bash +++ b/containers/ros/bashrc.d/ros_setup.bash @@ -1,3 +1,7 @@ +# Copyright (c) 2026 Tim Perkins + +# NOTE This script is expected to be sourced! + # Set up autocompletion, etc source "/usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" source "/usr/share/colcon_cd/function/colcon_cd.sh"