File tree Expand file tree Collapse file tree 2 files changed +36
-51
lines changed Expand file tree Collapse file tree 2 files changed +36
-51
lines changed Original file line number Diff line number Diff line change
1
+ # Stage 1: Build the Rust application
2
+ FROM rust:latest AS builder
3
+
4
+ # Set the working directory
5
+ WORKDIR /usr/src/app
6
+
7
+ # Copy the local dependencies
8
+ COPY ../entity/Cargo.toml entity/
9
+ COPY ../entity_api/Cargo.toml entity_api/
10
+
11
+ # Copy the Cargo.toml and Cargo.lock files to leverage Docker's caching
12
+ COPY Cargo.toml Cargo.lock ./
13
+
14
+ # Fetch the dependencies
15
+ RUN cargo fetch
16
+
17
+ # Copy the source code into the working directory
18
+ COPY . .
19
+
20
+ # Build the application in release mode
21
+ RUN cargo build --release
22
+
23
+ # Stage 2: Create a minimal runtime image
24
+ FROM alpine:latest
25
+
26
+ # Install necessary runtime dependencies
27
+ RUN apk add --no-cache libgcc
28
+
29
+ # Set the working directory
30
+ WORKDIR /usr/src/app
31
+
32
+ # Copy the compiled binary from the builder stage
33
+ COPY --from=builder /usr/src/app/target/release/your_binary_name .
34
+
35
+ # Set the entrypoint to the binary
36
+ ENTRYPOINT ["./your_binary_name"]
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments