nishantcoder108 commited on
Commit
73aa2d4
·
1 Parent(s): 208f2cf

refactor: update dockerfile for deploy

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -37
Dockerfile CHANGED
@@ -1,37 +1,35 @@
1
- # --- Stage 1: Fast Build Cache ---
2
- # CHANGED: Upgraded from 1.78 to 1.85 to support Rust 2024 Edition
3
- FROM rust:1.85-slim AS builder
4
- # Set the working directory to '/app' in the builder stage
5
- WORKDIR /app
6
-
7
- # Install system dependencies required for compilation toolchains in the builder stage
8
- # This includes 'pkg-config' which is used to locate the needed header files and libraries for compilation,
9
- # and 'libssl-dev' which includes the OpenSSL development libraries and header files.
10
- RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
11
-
12
- # Copy the entire project source tree from the host machine to the builder stage
13
- COPY . .
14
-
15
- # Compile the project binary in release mode (optimized for performance) in the builder stage
16
- RUN cargo build --release
17
-
18
- # --- Stage 2: Minimal Distroless Runtime ---
19
- # Start a new build stage named 'builder' using the 'debian:bookworm-slim' base image
20
- FROM debian:bookworm-slim
21
- # Set the working directory to '/app' in the runtime stage
22
- WORKDIR /app
23
-
24
- # Install OpenSSL certificates so the binary can securely talk to external database APIs in the runtime stage
25
- RUN apt-get update && apt-get install -y ca-certificates libssl3 && rm -rf /var/lib/apt/lists/*
26
-
27
- # Copy the compiled binary from the builder stage to the runtime stage
28
- # IMPORTANT: Change 'your_binary_name' to the exact name specified in your Cargo.toml file under [package] name
29
- COPY --from=builder /app/target/release/urlvibe-rs ./rust_engine
30
-
31
- # Expose the standard Hugging Face proxy entry port
32
- EXPOSE 7860
33
- # Set the environment variable 'PORT' to '7860'
34
- ENV PORT=7860
35
-
36
- # Execute the light binary in the runtime stage
37
- CMD ["./rust_engine"]
 
1
+ # ---------- Builder ----------
2
+ FROM rust:1.88-slim AS builder
3
+
4
+ WORKDIR /app
5
+
6
+ RUN apt-get update && apt-get install -y \
7
+ pkg-config \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ COPY Cargo.toml Cargo.lock ./
11
+
12
+ RUN mkdir src && echo "fn main() {}" > src/main.rs
13
+
14
+ RUN cargo build --release
15
+
16
+ COPY . .
17
+
18
+ RUN cargo build --release
19
+
20
+ # ---------- Runtime ----------
21
+ FROM debian:bookworm-slim
22
+
23
+ WORKDIR /app
24
+
25
+ RUN apt-get update && apt-get install -y \
26
+ ca-certificates \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ COPY --from=builder /app/target/release/urlvibe-rs ./rust_engine
30
+
31
+ ENV PORT=7860
32
+
33
+ EXPOSE 7860
34
+
35
+ CMD ["./rust_engine"]