aboutsummaryrefslogtreecommitdiff
path: root/templates/rust/Dockerfile
diff options
context:
space:
mode:
Diffstat (limited to 'templates/rust/Dockerfile')
-rw-r--r--templates/rust/Dockerfile22
1 files changed, 22 insertions, 0 deletions
diff --git a/templates/rust/Dockerfile b/templates/rust/Dockerfile
new file mode 100644
index 0000000..c1d3144
--- /dev/null
+++ b/templates/rust/Dockerfile
@@ -0,0 +1,22 @@
+FROM clux/muslrust:nightly-2025-04-18 AS chef
+USER root
+RUN cargo install cargo-chef
+WORKDIR /app
+
+FROM chef AS planner
+COPY . .
+RUN rm rust-toolchain.toml
+RUN cargo chef prepare --recipe-path recipe.json
+
+FROM chef AS builder
+COPY --from=planner /app/recipe.json recipe.json
+# Notice that we are specifying the --target flag!
+RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
+COPY . .
+RUN rm rust-toolchain.toml
+RUN cargo build --release --target x86_64-unknown-linux-musl --bin helios
+
+FROM docker.io/alpine:3 AS runtime
+WORKDIR /app
+COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/helios /usr/local/bin/
+CMD ["/usr/local/bin/helios"]