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
3 changes: 3 additions & 0 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ COPY --chown=${USERNAME}:${USERNAME} assets/.bashrc /home/${USERNAME}/.bashrc

USER ${USERNAME}
WORKDIR /workspaces

ENV HISTFILE=/home/${USERNAME}/.local/state/bash/history
RUN mkdir -p "${HISTFILE%/*}"
6 changes: 6 additions & 0 deletions debian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ The image runs as the non-root user `dev` (UID/GID 1000) and its working directo
Container clients pick up the user without extra configuration. Every image built on this one
inherits that label.

`dev`'s login shell is bash, which appends each command to `$HISTFILE` as it is entered rather
than at exit. `HISTFILE` is `/home/dev/.local/state/bash/history` rather than the default
`~/.bash_history`, and that directory is created in the image, so mounting a volume on it keeps
the shell history across container rebuilds, which is what the
[Dev Container template](#dev-container-template) does.

## Not installed

- **No development headers beyond libc.** `build-essential` covers the compiler, linker, and
Expand Down
3 changes: 3 additions & 0 deletions debian/assets/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ HISTCONTROL=ignoreboth
HISTSIZE=${HISTSIZE:-10000}
HISTFILESIZE=${HISTFILESIZE:-20000}
shopt -s histappend
# Append each command to HISTFILE as it is entered. Waiting for the shell to exit
# loses the session when the container is stopped before bash gets to write it.
PROMPT_COMMAND=${PROMPT_COMMAND:+${PROMPT_COMMAND}$'\n'}'history -a'

# Check terminal size after each command.
shopt -s checkwinsize
Expand Down
3 changes: 3 additions & 0 deletions debian/smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ git --version
cc --version
make --version

echo "=== Verifying the shell history directory is writable ==="
[ -w "${HISTFILE%/*}" ]

echo "=== Verifying the C toolchain compiles and links ==="
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
Expand Down