-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add and install nix as tool #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e2e7319
feat: add and install nix as tool
matttrach 0f27d7f
Merge branch 'main' into add-nix
matttrach 1f830f6
fix: adjust to new hook system
matttrach e6891fd
fix: remove is script url function
matttrach 5655201
fix: add version variable in docker template
matttrach bf3e26b
Merge branch 'main' into add-nix
matttrach 9490490
Merge branch 'main' into add-nix
matttrach 3d639e8
fix: update to changes and add config nix directory
matttrach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| FROM registry.suse.com/bci/bci-base:15.7@sha256:3292c81fb9e40b60903e6c88fac34e955b6d5b3acd3eb055d02d5c1538a72aea | ||
|
|
||
| LABEL org.opencontainers.image.source="https://github.com/rancher/ci-image" \ | ||
| org.opencontainers.image.title="Rancher nix CI image" \ | ||
| org.opencontainers.image.description="Nix environment" | ||
|
|
||
| ARG TARGETARCH | ||
| ENV ARCH=$TARGETARCH | ||
| ENV GH_TELEMETRY=false | ||
| ENV DO_NOT_TRACK=true | ||
| ENV PATH="/var/ci-tools/active:${PATH}" | ||
|
|
||
| RUN zypper -n refresh && \ | ||
| zypper -n install \ | ||
| gettext-runtime \ | ||
| ca-certificates \ | ||
| docker \ | ||
| gawk \ | ||
| git-core \ | ||
| gzip \ | ||
| jq \ | ||
| make \ | ||
| tar \ | ||
| unzip \ | ||
| zstd \ | ||
| wget \ | ||
| sudo \ | ||
| vim \ | ||
| && \ | ||
| zypper -n clean -a && \ | ||
| rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2} | ||
|
|
||
| # Create runner group (GID 121) and user (UID 1001) early for use in tool installations. | ||
| # /var/ci-tools/ is set up with setgid (2755) so subdirectories inherit the runner group. | ||
| # This allows any user added to the runner group to access tools extracted to /var/ci-tools/. | ||
| RUN groupadd -g 121 runner && \ | ||
| useradd -u 1001 -g 121 -m runner && \ | ||
| mkdir -p /var/ci-tools && \ | ||
| chown root:runner /var/ci-tools && \ | ||
| chmod 2755 /var/ci-tools | ||
|
|
||
| # cosign v3.0.6 | ||
| RUN case "${ARCH}" in \ | ||
| amd64) CHECKSUM="c956e5dfcac53d52bcf058360d579472f0c1d2d9b69f55209e256fe7783f4c74" ;; \ | ||
| arm64) CHECKSUM="bedac92e8c3729864e13d4a17048007cfafa79d5deca993a43a90ffe018ef2b8" ;; \ | ||
| *) echo "Unsupported: ${ARCH}"; exit 1 ;; \ | ||
| esac && \ | ||
| export TMP_DIR=$(mktemp -d) && \ | ||
| case "${ARCH}" in \ | ||
| amd64) DOWNLOAD_URL="https://github.com/sigstore/cosign/releases/download/v3.0.6/cosign-linux-amd64" ;; \ | ||
| arm64) DOWNLOAD_URL="https://github.com/sigstore/cosign/releases/download/v3.0.6/cosign-linux-arm64" ;; \ | ||
| esac && \ | ||
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors "${DOWNLOAD_URL}" > "${TMP_DIR}/cosign" && \ | ||
| printf "%s %s\n" "${CHECKSUM}" "${TMP_DIR}/cosign" > "${TMP_DIR}/checksum.sha256" && \ | ||
| sha256sum -c "${TMP_DIR}/checksum.sha256" && \ | ||
| install "${TMP_DIR}/cosign" "/usr/local/bin/cosign" && \ | ||
| rm -rf "${TMP_DIR}" | ||
|
|
||
| # gh v2.89.0 | ||
| RUN case "${ARCH}" in \ | ||
| amd64) CHECKSUM="d0422caade520530e76c1c558da47daebaa8e1203d6b7ff10ad7d6faba3490d8" ;; \ | ||
| arm64) CHECKSUM="9e64a623dfc242990aa5d9b3f507111149c4282f66b68eaad1dc79eeb13b9ce5" ;; \ | ||
| *) echo "Unsupported: ${ARCH}"; exit 1 ;; \ | ||
| esac && \ | ||
| export TMP_DIR=$(mktemp -d) && \ | ||
| export TMP_FILE="${TMP_DIR}/gh.tar.gz" && \ | ||
| case "${ARCH}" in \ | ||
| amd64) DOWNLOAD_URL="https://github.com/cli/cli/releases/download/v2.89.0/gh_2.89.0_linux_amd64.tar.gz"; EXTRACT="gh_2.89.0_linux_amd64/bin/gh" ;; \ | ||
| arm64) DOWNLOAD_URL="https://github.com/cli/cli/releases/download/v2.89.0/gh_2.89.0_linux_arm64.tar.gz"; EXTRACT="gh_2.89.0_linux_arm64/bin/gh" ;; \ | ||
| esac && \ | ||
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors "${DOWNLOAD_URL}" > "${TMP_FILE}" && \ | ||
| printf "%s %s\n" "${CHECKSUM}" "${TMP_FILE}" > "${TMP_DIR}/checksum.sha256" && \ | ||
| sha256sum -c "${TMP_DIR}/checksum.sha256" && \ | ||
| tar xzf "${TMP_FILE}" -C "${TMP_DIR}" && \ | ||
| install "${TMP_DIR}/${EXTRACT}" "/usr/local/bin/gh" && \ | ||
| rm -rf "${TMP_DIR}" | ||
|
|
||
| # helmv3 v3.20.2 | ||
| RUN case "${ARCH}" in \ | ||
| amd64) CHECKSUM="258e830a9e613c8a7a302d6059b4bb3b9758f2f3e1bb8ea0d707ce10a9a72fea" ;; \ | ||
| arm64) CHECKSUM="5ea2d6bc2cda3f8edf985e028809f5a9278f404fb8ab24044de9b7cb9b79a691" ;; \ | ||
| *) echo "Unsupported: ${ARCH}"; exit 1 ;; \ | ||
| esac && \ | ||
| export TMP_DIR=$(mktemp -d) && \ | ||
| export TMP_FILE="${TMP_DIR}/helmv3.tar.gz" && \ | ||
| case "${ARCH}" in \ | ||
| amd64) DOWNLOAD_URL="https://get.helm.sh/helm-v3.20.2-linux-amd64.tar.gz"; EXTRACT="linux-amd64/helm" ;; \ | ||
| arm64) DOWNLOAD_URL="https://get.helm.sh/helm-v3.20.2-linux-arm64.tar.gz"; EXTRACT="linux-arm64/helm" ;; \ | ||
| esac && \ | ||
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors "${DOWNLOAD_URL}" > "${TMP_FILE}" && \ | ||
| printf "%s %s\n" "${CHECKSUM}" "${TMP_FILE}" > "${TMP_DIR}/checksum.sha256" && \ | ||
| sha256sum -c "${TMP_DIR}/checksum.sha256" && \ | ||
| tar xzf "${TMP_FILE}" -C "${TMP_DIR}" && \ | ||
| install "${TMP_DIR}/${EXTRACT}" "/usr/local/bin/helmv3" && \ | ||
| rm -rf "${TMP_DIR}" | ||
|
|
||
| # helmv4 v4.1.4 | ||
| RUN case "${ARCH}" in \ | ||
| amd64) CHECKSUM="70b2c30a19da4db264dfd68c8a3664e05093a361cefd89572ffb36f8abfa3d09" ;; \ | ||
| arm64) CHECKSUM="13d03672be289045d2ff00e4e345d61de1c6f21c1257a45955a30e8ae036d8f1" ;; \ | ||
| *) echo "Unsupported: ${ARCH}"; exit 1 ;; \ | ||
| esac && \ | ||
| export TMP_DIR=$(mktemp -d) && \ | ||
| export TMP_FILE="${TMP_DIR}/helmv4.tar.gz" && \ | ||
| case "${ARCH}" in \ | ||
| amd64) DOWNLOAD_URL="https://get.helm.sh/helm-v4.1.4-linux-amd64.tar.gz"; EXTRACT="linux-amd64/helm" ;; \ | ||
| arm64) DOWNLOAD_URL="https://get.helm.sh/helm-v4.1.4-linux-arm64.tar.gz"; EXTRACT="linux-arm64/helm" ;; \ | ||
| esac && \ | ||
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors "${DOWNLOAD_URL}" > "${TMP_FILE}" && \ | ||
| printf "%s %s\n" "${CHECKSUM}" "${TMP_FILE}" > "${TMP_DIR}/checksum.sha256" && \ | ||
| sha256sum -c "${TMP_DIR}/checksum.sha256" && \ | ||
| tar xzf "${TMP_FILE}" -C "${TMP_DIR}" && \ | ||
| install "${TMP_DIR}/${EXTRACT}" "/usr/local/bin/helmv4" && \ | ||
| rm -rf "${TMP_DIR}" | ||
|
|
||
| # slsactl v0.1.30 | ||
| RUN case "${ARCH}" in \ | ||
| amd64) CHECKSUM="7ed4750766c135ddcae788d194d7ff59a57c6debdc722fd1e52c06460218f10a" ;; \ | ||
| arm64) CHECKSUM="bbbe66089135c82526677177c080f5ca4911ad1989712596338c5acdae4bb383" ;; \ | ||
| *) echo "Unsupported: ${ARCH}"; exit 1 ;; \ | ||
| esac && \ | ||
| export TMP_DIR=$(mktemp -d) && \ | ||
| export TMP_FILE="${TMP_DIR}/slsactl.tar.gz" && \ | ||
| case "${ARCH}" in \ | ||
| amd64) DOWNLOAD_URL="https://github.com/rancherlabs/slsactl/releases/download/v0.1.30/slsactl_0.1.30_linux_amd64.tar.gz"; EXTRACT="slsactl" ;; \ | ||
| arm64) DOWNLOAD_URL="https://github.com/rancherlabs/slsactl/releases/download/v0.1.30/slsactl_0.1.30_linux_arm64.tar.gz"; EXTRACT="slsactl" ;; \ | ||
| esac && \ | ||
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors "${DOWNLOAD_URL}" > "${TMP_FILE}" && \ | ||
| printf "%s %s\n" "${CHECKSUM}" "${TMP_FILE}" > "${TMP_DIR}/checksum.sha256" && \ | ||
| sha256sum -c "${TMP_DIR}/checksum.sha256" && \ | ||
| tar xzf "${TMP_FILE}" -C "${TMP_DIR}" && \ | ||
| install "${TMP_DIR}/${EXTRACT}" "/usr/local/bin/slsactl" && \ | ||
| rm -rf "${TMP_DIR}" | ||
|
|
||
| # yq v4.53.2 | ||
| RUN case "${ARCH}" in \ | ||
| amd64) CHECKSUM="d56bf5c6819e8e696340c312bd70f849dc1678a7cda9c2ad63eebd906371d56b" ;; \ | ||
| arm64) CHECKSUM="03061b2a50c7a498de2bbb92d7cb078ce433011f085a4994117c2726be4106ea" ;; \ | ||
| *) echo "Unsupported: ${ARCH}"; exit 1 ;; \ | ||
| esac && \ | ||
| export TMP_DIR=$(mktemp -d) && \ | ||
| case "${ARCH}" in \ | ||
| amd64) DOWNLOAD_URL="https://github.com/mikefarah/yq/releases/download/v4.53.2/yq_linux_amd64" ;; \ | ||
| arm64) DOWNLOAD_URL="https://github.com/mikefarah/yq/releases/download/v4.53.2/yq_linux_arm64" ;; \ | ||
| esac && \ | ||
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors "${DOWNLOAD_URL}" > "${TMP_DIR}/yq" && \ | ||
| printf "%s %s\n" "${CHECKSUM}" "${TMP_DIR}/yq" > "${TMP_DIR}/checksum.sha256" && \ | ||
| sha256sum -c "${TMP_DIR}/checksum.sha256" && \ | ||
| install "${TMP_DIR}/yq" "/usr/local/bin/yq" && \ | ||
| rm -rf "${TMP_DIR}" | ||
|
|
||
| # nix 2.34.7 | ||
|
|
||
| # Pre-install setup for nix | ||
| # Create unprivileged user for Nix installation | ||
| RUN useradd -m suse && \ | ||
| if [ ! -f /etc/sudoers ]; then touch /etc/sudoers; fi && \ | ||
| echo "suse ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
|
||
| # Add suse user to runner group and create /etc/nix directory and configuration | ||
| RUN usermod -a -G runner suse && \ | ||
| sudo mkdir -p /etc/nix && \ | ||
| printf "build-users-group =\nsandbox = false\nfilter-syscalls = false\n" > /etc/nix/nix.conf && \ | ||
| sudo chown -R suse:runner /etc/nix && \ | ||
| sudo mkdir -p /nix && \ | ||
| sudo chown -R suse:runner /nix && \ | ||
| echo 'source /home/suse/.nix-profile/etc/profile.d/nix.sh' > /etc/profile.d/nix.sh && \ | ||
| echo 'source /home/suse/.nix-profile/etc/profile.d/nix.sh' > /etc/bash.bashrc.local | ||
|
|
||
| RUN case "${ARCH}" in \ | ||
| amd64) CHECKSUM="eafe5042404e818505e28c5ca3d0885f3ec45c31f955489a25bb38258f87560e" ;; \ | ||
| arm64) CHECKSUM="f1cee64ae7a02330c6421924c28f597c41813f2214ff108622087d8056378b08" ;; \ | ||
| *) echo "Unsupported: ${ARCH}"; exit 1 ;; \ | ||
| esac && \ | ||
| export INSTALL_DIR="/var/ci-tools/nix" && \ | ||
| mkdir -p "${INSTALL_DIR}" && \ | ||
| export TMP_DIR=$(mktemp -d) && \ | ||
| export TMP_FILE="${TMP_DIR}/nix.tar.xz" && \ | ||
| case "${ARCH}" in \ | ||
| amd64) DOWNLOAD_URL="https://releases.nixos.org/nix/nix-2.34.7/nix-2.34.7-x86_64-linux.tar.xz"; EXTRACT="nix-2.34.7-x86_64-linux/" ;; \ | ||
| arm64) DOWNLOAD_URL="https://releases.nixos.org/nix/nix-2.34.7/nix-2.34.7-aarch64-linux.tar.xz"; EXTRACT="nix-2.34.7-aarch64-linux/" ;; \ | ||
| esac && \ | ||
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors "${DOWNLOAD_URL}" > "${TMP_FILE}" && \ | ||
| printf "%s %s\n" "${CHECKSUM}" "${TMP_FILE}" > "${TMP_DIR}/checksum.sha256" && \ | ||
| sha256sum -c "${TMP_DIR}/checksum.sha256" && \ | ||
| tar xJf "${TMP_FILE}" -C "${TMP_DIR}" && \ | ||
| FULL_EXTRACT_PATH="${TMP_DIR}/${EXTRACT}" && \ | ||
| EXTRACT_DIR=$(dirname "${FULL_EXTRACT_PATH}") && \ | ||
| if [ "${EXTRACT_DIR}" != "${TMP_DIR}" ]; then \ | ||
| cp -a "${FULL_EXTRACT_PATH}" "${INSTALL_DIR}/"; \ | ||
| else \ | ||
| (cd "${FULL_EXTRACT_PATH}" && cp -a . "${INSTALL_DIR}/"); \ | ||
| fi && \ | ||
| rm -rf "${TMP_DIR}" | ||
|
|
||
| # Post-install setup for nix | ||
| # Fix ownership and run Nix installer from the extracted archive | ||
| RUN set -e; \ | ||
| sudo chown -R suse:runner /var/ci-tools/nix | ||
|
|
||
| # Switch to unprivileged user for installation | ||
| USER suse | ||
| WORKDIR /home/suse | ||
| ENV USER=suse | ||
|
|
||
| RUN set -e; \ | ||
| cd /var/ci-tools/nix && \ | ||
| ./install --no-daemon | ||
|
|
||
| RUN set -e; \ | ||
| install -d .config/nix/profiles | ||
|
|
||
| # Restore root user for remaining Dockerfile operations | ||
| USER root | ||
| ENV USER=root | ||
|
|
||
| # Family selectors — copy scripts and set up manifest + active symlinks. | ||
| # /var/ci-tools/active is on PATH ahead of /usr/local/bin; runner can update | ||
| # the active symlink with: ci-select <family> <tool> or select-<family> <tool> | ||
| COPY dockerfiles/scripts/select-helm.sh /usr/local/bin/select-helm | ||
| COPY dockerfiles/scripts/ci-select.sh /usr/local/bin/ci-select | ||
| RUN chmod +x /usr/local/bin/select-helm && chmod +x /usr/local/bin/ci-select | ||
|
|
||
|
|
||
| # Set up CI tool family infrastructure (runner user and group created earlier). | ||
| RUN mkdir -p /var/ci-tools/active \ | ||
| && mkdir -p /usr/local/share/ci-tools/families/helm \ | ||
| && touch /usr/local/share/ci-tools/families/helm/helmv3 \ | ||
| && touch /usr/local/share/ci-tools/families/helm/helmv4 \ | ||
| && ln -sf helmv4 /usr/local/share/ci-tools/families/helm/default \ | ||
| && ln -sf /usr/local/bin/helmv4 /var/ci-tools/active/helm \ | ||
| && chown -R root:runner /var/ci-tools \ | ||
| && chmod 2775 /var/ci-tools/active | ||
|
|
||
| # We trust our base image and the repos that are pulled in workflows. Otherwise | ||
| # each workflow that uses our base images would have to add the step below. | ||
| RUN git config --system --add safe.directory '*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Fix ownership and run Nix installer from the extracted archive | ||
|
mallardduck marked this conversation as resolved.
|
||
| RUN set -e; \ | ||
| sudo chown -R suse:runner /var/ci-tools/nix | ||
|
|
||
| # Switch to unprivileged user for installation | ||
| USER suse | ||
| WORKDIR /home/suse | ||
| ENV USER=suse | ||
|
|
||
| RUN set -e; \ | ||
| cd /var/ci-tools/nix && \ | ||
| ./install --no-daemon | ||
|
|
||
| RUN set -e; \ | ||
| install -d .config/nix/profiles | ||
|
|
||
| # Restore root user for remaining Dockerfile operations | ||
| USER root | ||
| ENV USER=root | ||
|
mallardduck marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Create unprivileged user for Nix installation | ||
| RUN useradd -m suse && \ | ||
| if [ ! -f /etc/sudoers ]; then touch /etc/sudoers; fi && \ | ||
| echo "suse ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
|
||
| # Add suse user to runner group and create /etc/nix directory and configuration | ||
| RUN usermod -a -G runner suse && \ | ||
| sudo mkdir -p /etc/nix && \ | ||
| printf "build-users-group =\nsandbox = false\nfilter-syscalls = false\n" > /etc/nix/nix.conf && \ | ||
| sudo chown -R suse:runner /etc/nix && \ | ||
| sudo mkdir -p /nix && \ | ||
| sudo chown -R suse:runner /nix && \ | ||
| echo 'source /home/suse/.nix-profile/etc/profile.d/nix.sh' > /etc/profile.d/nix.sh && \ | ||
| echo 'source /home/suse/.nix-profile/etc/profile.d/nix.sh' > /etc/bash.bashrc.local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.