@@ -4,6 +4,7 @@ FROM debian:${BASE_VERSION}
44ARG USER_UID
55ARG USER_GID
66
7+ # Install base system requirements
78# hadolint ignore=DL3008
89RUN set -eux; \
910 apt-get update; \
@@ -19,6 +20,7 @@ RUN set -eux; \
1920 ; \
2021 rm -rf /var/lib/apt/lists/*
2122
23+ # Install buildevents
2224ARG BUILDEVENTS_VERSION=v0.17.0
2325RUN set -eux; \
2426 ARCH="$(dpkg --print-architecture)" ; \
@@ -31,49 +33,34 @@ RUN set -eux; \
3133 "https://github.com/honeycombio/buildevents/releases/download/${BUILDEVENTS_VERSION}/buildevents-${BUILDEVENTS_ARCH}" && \
3234 chmod +x /usr/local/bin/buildevents
3335
36+ # Setup workspace and git configuration
3437RUN set -eux; \
35- useradd --create-home --shell /bin/bash --uid "${USER_UID}" ci; \
36- echo 'ci ALL=(ALL:ALL) NOPASSWD: ALL' >/etc/sudoers.d/ci; \
37- mkdir -p /workdir; \
38- chown -R ci:ci /workdir
38+ mkdir -p /workspace; \
39+ git config --global --add safe.directory /workspace
3940
40- RUN groupadd -f docker && usermod -aG docker ci
41-
42- ENV USER=ci
43- USER ci:ci
44-
45- # hadolint ignore=DL3004,DL4006
41+ # Install Nix as root with daemon mode
4642RUN set -eux; \
47- sudo install -d -m755 -o $(id -u) -g $(id -g) /nix; \
48- curl \
49- --proto '=https' \
50- --tlsv1.2 -sSf \
51- -L https://nixos.org/nix/install \
52- | sh -s -- --no-daemon; \
53- mkdir -p "$HOME/.config/nix" ; \
43+ curl -L https://nixos.org/nix/install | sh -s -- --daemon; \
44+ mkdir -p /root/.config/nix; \
5445 { \
5546 echo 'extra-nix-path = nixpkgs=flake:nixpkgs' ; \
5647 echo 'experimental-features = nix-command flakes impure-derivations ca-derivations' ; \
5748 echo 'auto-optimise-store = true' ; \
5849 echo 'bash-prompt-prefix = (nix:$name)\0 40' ; \
59- } >"$HOME/.config/nix/nix.conf" ; \
60- . "$HOME/.nix-profile/etc/profile.d/nix.sh" ; \
61- nix-env -iA nixpkgs.nixVersions.stable; \
62- grep 'Nix installer' "$HOME/.profile" >>"$HOME/.bashrc" ; \
63- \
64- git config --global --add safe.directory /workdir; \
65- mkdir -p "$HOME/.ssh" ; \
66- chmod 0700 "$HOME/.ssh" ; \
67- ssh-keyscan github.com >>"$HOME/.ssh/known_hosts" ;
50+ } >"/root/.config/nix/nix.conf" ; \
51+ mkdir -p "/root/.ssh" ; \
52+ chmod 0700 "/root/.ssh" ; \
53+ ssh-keyscan github.com >>"/root/.ssh/known_hosts"
6854
69- WORKDIR /workdir
55+ WORKDIR /workspace
7056
57+ # Copy flake configuration and prebuild Nix environment
7158COPY flake.nix flake.lock rust-toolchain ./
72- COPY docker-entrypoint.sh /
7359
7460RUN set -eux; \
75- . "$HOME/.nix-profile/ etc/profile.d/nix.sh" ; \
61+ . / etc/profile.d/nix.sh; \
7662 nix develop .#ci --build; \
77- rm -f flake.nix flake.lock rust-toolchain
63+ CI_TOOLS=$(nix build --no-link --print-out-paths .#ci-tools); \
64+ cp -rs "$CI_TOOLS/bin/" * /usr/local/bin/ 2>/dev/null || true; \
65+ cp -rs "$CI_TOOLS/share" /usr/local/ 2>/dev/null || true
7866
79- ENTRYPOINT ["/docker-entrypoint.sh" ]
0 commit comments