diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a40b2cb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +target/ +.git/ +.gitignore +Dockerfile +.dockerignore +README.md +.env +*.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b86dbf1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM rust:1.94 AS chef + +RUN cargo install --locked cargo-chef +WORKDIR /app + +COPY Cargo.toml Cargo.lock . +RUN mkdir src && touch src/main.rs + +RUN cargo chef prepare --recipe-path recipe.json + + + +FROM chef AS builder + +COPY --from=chef /app/recipe.json recipe.json + +RUN cargo chef cook --release --recipe-path recipe.json + + +COPY rust-toolchain.toml rust-toolchain.toml + +RUN cargo fetch + + +COPY . . + +RUN cargo build --release + + + +FROM debian:bookworm-slim AS runtime + +RUN useradd -m -s /bin/bash appuser + +WORKDIR /app + +COPY --from=builder /app/target/release/mdpreview /usr/local/bin/mdpreview + +USER appuser + +EXPOSE 8080 + +CMD ["mdpreview"]