-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (39 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
50 lines (39 loc) · 1.27 KB
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
50
FROM rust:1.84.0-slim-bullseye AS build
# Install build dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
libssl-dev \
libclang-dev \
libudev-dev \
pkg-config \
wget \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create dummy project to take advantage of Docker cache for dependencies
RUN USER=root cargo new --bin block-entries-service
WORKDIR /block-entries-service
# Copy manifests and fetch dependencies first (for caching)
COPY Cargo.toml Cargo.lock ./
RUN mkdir -p src && echo 'fn main() {}' > src/main.rs
RUN cargo build --release
RUN rm -rf src
# Copy actual source and build
COPY . .
RUN cargo build --release
# Final image
FROM rust:1.84.0-slim-bullseye
# Minimal runtime dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/local/bin
# Copy binary from builder
COPY --from=build /block-entries-service/target/release/block-entries-service .
# Ensure it's executable
RUN chmod +x block-entries-service
# Logging level (optional)
ENV RUST_LOG=info
ENTRYPOINT ["./block-entries-service"]