-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
49 lines (37 loc) · 1.29 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Stage 1: Build the Rust application
FROM rust:1.81.0 AS builder
# Set the working directory inside the container
WORKDIR /usr/src/app
# Install protobuf compiler (protoc)
RUN apt-get update && \
apt-get install -y protobuf-compiler && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy the Cargo.toml and Cargo.lock files to fetch dependencies
COPY Cargo.toml Cargo.lock ./
# Pre-fetch the dependencies to speed up the build process
RUN cargo fetch
# Copy the remaining source code
COPY . .
# Build the application in release mode
RUN cargo build --release
# Stage 2: Create the final image with the necessary dependencies
FROM debian:bookworm-slim
# Update package lists and install necessary dependencies for running the application
RUN apt-get update && \
apt-get install -y \
curl \
libssl3 \
libssl-dev \
pkg-config \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy the compiled binary from the builder stage to the final image
COPY --from=builder /usr/src/app/target/release/ring_bench_rs /usr/local/bin/ring_bench_rs
# Set the working directory for the application
WORKDIR /usr/src/app
# Copy the configuration file into the container
COPY resources/config.toml ./resources/
# Command to run the application
CMD ["ring_bench_rs"]