-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (35 loc) · 990 Bytes
/
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
# Build stage
FROM rust:1.83-slim-bullseye AS builder
# Set environment variables
ENV RUST_BACKTRACE=1
ENV RUST_LOG=info
# Set the working directory
WORKDIR /app
# Install OpenSSL development packages and pkg-config
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy manifest files
COPY Cargo.toml Cargo.lock ./
# Copy source code
COPY src ./src
# Build the application
RUN cargo build --release
# Runtime stage
FROM debian:bullseye-slim
# Set the working directory
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libssl1.1 \
&& rm -rf /var/lib/apt/lists/*
# Copy config file
COPY config.yml /app/config.yml
# Expose port for Prometheus metrics
EXPOSE 9100
# Copy the binary from builder
COPY --from=builder /app/target/release/rust /usr/local/bin/app
# Define the default command
CMD ["app"]