From 527c5d502d02c549f635fe0a4b5a9c3932de8da6 Mon Sep 17 00:00:00 2001
From: Louis <contact@louiscap.co>
Date: Fri, 31 Jan 2025 19:32:31 +0000
Subject: [PATCH] Include cargo cross in image, bump rust version, restrict
 image building to tags

---
 .gitlab-ci.yml | 5 ++++-
 Dockerfile     | 7 ++++++-
 README.md      | 9 +++++++--
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e3a659c..750a3d7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -15,4 +15,7 @@ build:
         echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
       fi
     - docker build --pull -f Dockerfile -t "$CI_REGISTRY_IMAGE${tag}" .
-    - docker push "$CI_REGISTRY_IMAGE${tag}"
\ No newline at end of file
+    - docker push "$CI_REGISTRY_IMAGE${tag}"
+  rules:
+    if: $CI_COMMIT_TAG
+        when: always
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 3433180..5e1ed1c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,7 +7,7 @@ ARG USER_GID=$USER_UID
 ARG RUST_VERSION
 ARG NODE_VERSION
 
-ENV RUST_VERSION=${RUST_VERSION:-1.82}
+ENV RUST_VERSION=${RUST_VERSION:-1.84}
 ENV NODE_VERSION=${NODE_VERSION:-22.11.0}
 
 RUN groupadd --gid $USER_GID $USERNAME \
@@ -35,4 +35,9 @@ RUN rustup install $RUST_VERSION && \
     rustup install nightly && \
     cargo install cargo-binstall junitify cargo-nextest
 
+RUN cargo install cross --git https://github.com/cross-rs/cross
+
+ENV CROSS_CONTAINER_IN_CONTAINER=true
+ENV CROSS_CONTAINER_UID=${USER_UID}
+ENV CROSS_CONTAINER_GID=${USER_GID}
 ENV PATH="${PATH}:/home/${USERNAME}/.cargo/bin:${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/"
\ No newline at end of file
diff --git a/README.md b/README.md
index 4128b56..8914b4d 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Rust base image for use in Gitlab CI. Includes extra tools to support the CI use
 To use this image as the base for your CI pipeline, include the following at the head of your `.gitlab-ci.yml`:
 
 ```yaml
-image: cr.weirdboi.dev/base/rust:1.82
+image: cr.weirdboi.dev/base/rust:1.84
 ```
 
 To use this image for a specific pipeline job, include the following in your job spec:
@@ -36,4 +36,9 @@ my_build_step:
 
 ### Extra Binaries
 
-- `junitify` - Can be used to transform the output of `cargo test` into a junit.xml file
\ No newline at end of file
+- `junitify` - Can be used to transform the output of `cargo test` into a junit.xml file
+- `node` - Node.js javascript runtime
+
+### Cross support
+
+- The container also includes `cross`, but does not install additional toolchains by default. This can be used to avoid prebuilding additional image versions in environments with DinD support
\ No newline at end of file
-- 
GitLab