Skip to content

Commit

Permalink
Added Rust/Cargo example project to the container image.
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltrick committed Aug 31, 2024
1 parent 421a803 commit da35d90
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## r4 - 2024-08-30
## r4 - 2024-08-31

### Changed
- Switched base system from `debian:bookworm-slim` to `bitnami/minideb:bookworm`
- Switched base system from `debian:bookworm-slim` to `bitnami/minideb:bookworm`.

### Added
- Added example Rust/Cargo project to the container image.

## r3 - 2024-08-30

Expand Down
27 changes: 20 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ RUN install_packages \
rdfind

# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=${RUST_VERSION} --profile=minimal -y \
&& rdfind -makeresultsfile false -makesymlinks true /root
RUN curl https://sh.rustup.rs -sSf | \
CARGO_HOME=/opt/rust/cargo RUSTUP_HOME=/opt/rust/rustup \
sh -s -- --default-toolchain=${RUST_VERSION} --profile=minimal -y \
&& rdfind -makeresultsfile false -makesymlinks true /opt/rust/

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Stage #2
Expand All @@ -37,10 +39,21 @@ RUN install_packages \
pkg-config

# Copy Rust/Cargo files
COPY --from=build /root/ /root/
COPY --from=build /opt/rust/ /opt/rust/

# Create symlinks
RUN ln -s -t /usr/local/bin /root/.cargo/bin/*
# Copy entry-point script
COPY bin/entry-point.sh /opt/rust/entry-point.sh

# Start the shell
ENTRYPOINT ["/bin/bash"]
# Copy example project
COPY src/example/ /var/opt/rust/src/

# Set up environment
ENV RUSTUP_HOME=/opt/rust/rustup
ENV CARGO_HOME=/opt/rust/cargo
ENV CARGO_TARGET_DIR=/var/tmp/rust/target

# Working directory
WORKDIR /var/opt/rust/src

# Entry point
ENTRYPOINT ["/opt/rust/entry-point.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ Version history

| **Release** | **Date** | **Base system** | **Rust toolchain** | **TPM2 Software Stack** |
| ----------- | ---------- | ------------------------------ | ------------------ | ----------------------- |
| r4 | 2024-08-30 | Minideb "Bookworm", 2024-08-30 | 1.80.0 | 3.2.1-3 |
| r4 | 2024-08-31 | Minideb "Bookworm", 2024-08-31 | 1.80.0 | 3.2.1-3 |
| r3 | 2024-08-30 | Debian 12, 2024-08-12 | 1.80.0 | 3.2.1-3 |
4 changes: 4 additions & 0 deletions bin/entry-point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
. "${CARGO_HOME}/env"
set -x
cargo "${@:-build}"
6 changes: 6 additions & 0 deletions src/example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "src"
version = "0.1.0"
edition = "2021"

[dependencies]
3 changes: 3 additions & 0 deletions src/example/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

0 comments on commit da35d90

Please sign in to comment.