Files
shadow/docker/Dockerfile.e2e
T

69 lines
2.2 KiB
Docker
Raw Permalink Normal View History

2026-04-03 13:22:55 +02:00
# shadow-rs end-to-end deployment test image
#
# Simulates a real deployment: build from source, install system-wide
# (replacing GNU shadow-utils), then run ~100 assertions.
#
# Usage:
# docker compose build e2e
# docker compose run --rm e2e # run all tests
# docker compose run --rm e2e bash # debug interactively
# ── Stage 1: build shadow-rs ────────────────────────────────────────
# Pinned: see the note in Dockerfile.debian.
FROM rust:1.98-trixie AS builder
2026-04-03 13:22:55 +02:00
RUN apt-get update && apt-get install -y --no-install-recommends \
libpam0g-dev \
libselinux1-dev \
libaudit-dev \
pkg-config \
make \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
# The multicall layout the release archive uses: one setuid binary plus
# symlinks. Its build target enables `pam`.
RUN make install-multicall DESTDIR=/install PREFIX=/usr
2026-04-03 13:22:55 +02:00
# ── Stage 2: runtime with tests ────────────────────────────────────
FROM debian:13
2026-04-03 13:22:55 +02:00
# Install GNU shadow-utils first — this creates /etc/pam.d/passwd,
# /etc/pam.d/su, and other PAM configs we need. We overwrite the
# binaries below but keep the PAM configuration intact.
RUN apt-get update && apt-get install -y --no-install-recommends \
passwd \
login \
&& rm -rf /var/lib/apt/lists/*
# Overwrite GNU binaries with shadow-rs. Both directories: the tools an
# ordinary user runs live in bin, as they do in the GNU package, and sbin is
# not on a normal user's PATH.
2026-04-03 13:22:55 +02:00
COPY --from=builder /install/usr/sbin/ /usr/sbin/
COPY --from=builder /install/usr/bin/ /usr/bin/
2026-04-03 13:22:55 +02:00
# Setuid-root — chmod on symlink sets the bit on the target binary
RUN chmod 4755 /usr/sbin/shadow-rs
# Install test dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
expect \
nscd \
rsyslog \
2026-04-03 13:22:55 +02:00
ansible-core \
python3-passlib \
procps \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root test runner using our own tools
RUN /usr/sbin/useradd -m -s /bin/bash testrunner
# Copy test scripts
COPY tests/e2e/ /tests/e2e/
RUN chmod +x /tests/e2e/deploy-test.sh
WORKDIR /tests/e2e
CMD ["./deploy-test.sh"]