From a792d2667825ebaf81e8ea447b1c0f36e3397e1e Mon Sep 17 00:00:00 2001 From: Barry Pederson Date: Sun, 3 Nov 2024 20:09:41 -0800 Subject: [PATCH] Add Dockerfile --- Dockerfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..30f2cc2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +################ +##### Builder +FROM rust:1.82.0-slim AS builder + +WORKDIR /usr/src + +COPY . /usr/src + +## Install target platform (Cross-Compilation) --> Needed for Alpine +RUN rustup target add x86_64-unknown-linux-musl + +# This is a dummy build to get the dependencies cached. +RUN cargo build --target x86_64-unknown-linux-musl --release + +## Touch main.rs to prevent cached release build +RUN touch /usr/src/server/src/main.rs + +# This is the actual application build. +RUN cargo build --package server --target x86_64-unknown-linux-musl --release + +################ +##### Runtime +FROM alpine:3.20.3 AS runtime + +# Copy application binary from builder image +COPY --from=builder /usr/src/target/x86_64-unknown-linux-musl/release/saslauthd /usr/local/bin + + +# Run the application +CMD ["/usr/local/bin/saslauthd"] \ No newline at end of file