Files
dotfiles-public/.tests/lab/Dockerfile
T
bcherb2 a001406a33 test: container lab for the two-tier apply
A disposable ubuntu container, a fake private tier and a fake bootstrap
endpoint, so the whole documented path — chezmoi init --apply, dotup pick,
dotup private, cmp apply, dotsecrets — can run end to end without touching a
real machine or a real credential. The fake tier mirrors the real one's
structure (seven secrets and one alias) because dotsecrets is copied verbatim
and the "8 exports, not 7" assertion depends on that cardinality; its ids are
sequential and obviously synthetic.

check-verbatim.sh keeps the fake tier's copies of shipped files honest, and
snapshot.sh records file modes so a 644 where a 600 belongs is a diff.
2026-08-21 22:34:53 -04:00

43 lines
1.7 KiB
Docker

# A box shaped like one you would actually be handed, not one shaped to make
# the tests pass.
#
# Three details are load-bearing, and each of them hid a real bug:
#
# non-root user the old harness ran as root, where ~/.local/bin, sudo and
# $HOME all behave differently.
# bash login Ubuntu's own ~/.profile prepends ~/.local/bin ONLY if that
# directory already exists when the shell starts. A session
# opened before the install therefore does NOT have it, which
# is precisely why `dotup` came back "command not found" on a
# real machine and never once in CI.
# curl but no git the cloud images ship curl; git arrives with chezmoi's
# installer or not at all.
#
# Nothing else is pre-installed. Anything the tests need beyond this -- expect,
# zsh -- is installed by the scenario that needs it, so a dependency can never
# be silently satisfied by the image.
ARG BASE=ubuntu:24.04
FROM ${BASE}
ARG USER=ben
ARG UID=1001
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get install -y -qq --no-install-recommends \
ca-certificates curl sudo locales tzdata \
&& locale-gen en_US.UTF-8 >/dev/null 2>&1 \
&& rm -rf /var/lib/apt/lists/*
# `ubuntu` already owns 1000 in 24.04, so take the next id rather than fighting
# it. Passwordless sudo matches a cloud image; the installer must never assume
# it, but it must work when it is there.
RUN useradd -m -u ${UID} -s /bin/bash ${USER} \
&& printf '%s ALL=(ALL) NOPASSWD:ALL\n' "${USER}" > /etc/sudoers.d/90-${USER} \
&& chmod 440 /etc/sudoers.d/90-${USER}
ENV LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
USER ${USER}
WORKDIR /home/${USER}
CMD ["sleep", "infinity"]