From 57d86ba05742bf78dd97673372741afdf02e8447 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Wed, 16 Jul 2025 14:10:33 +0300 Subject: [PATCH 1/2] chore(docker): migrate to rust-chef --- .dockerignore | 10 ++++++++++ Dockerfile | 18 +++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9b6ee80 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +target/ +.git/ +.gitignore +README.md +Dockerfile +.dockerignore +*.log +.env +.vscode/ +.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 81a755a..7be154d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,23 @@ -FROM rust:1.87-bookworm AS builder - +FROM lukemathwalker/cargo-chef:0.1.71-rust-1.87-bookworm AS chef WORKDIR /app + +FROM chef AS planner +COPY . . +RUN cargo chef prepare --bin hub --recipe-path recipe.json + +FROM chef AS builder +# Install OpenSSL development libraries and pkg-config for Debian +RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/* +COPY --from=planner /app/recipe.json recipe.json +# Build dependencies - this is the caching Docker layer! +RUN cargo chef cook --release --recipe-path recipe.json +# Build application COPY . . RUN cargo build --release --bin hub +# We do not need the Rust toolchain to run the binary! FROM debian:bookworm-slim AS runtime -RUN apt-get update && apt-get install -y openssl ca-certificates +RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY --from=builder /app/target/release/hub /usr/local/bin WORKDIR /etc From 0f88ee5fea26a9c1aa8f2febd8b61e17a675137a Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Wed, 16 Jul 2025 17:40:38 +0300 Subject: [PATCH 2/2] add management port --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7be154d..20624aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,9 @@ WORKDIR /app COPY --from=builder /app/target/release/hub /usr/local/bin WORKDIR /etc -ENV PORT 3000 +ENV PORT=3000 +ENV MANAGEMENT_PORT=8080 EXPOSE 3000 +EXPOSE 8080 ENTRYPOINT ["/usr/local/bin/hub"]