-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
56 lines (51 loc) · 1.26 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
50
51
52
53
54
55
56
# --- Cargo Chef Stage (for caching dependencies) ---
FROM rust:1.78.0-bookworm as chef
WORKDIR /app
RUN cargo install cargo-chef
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# --- Dependency Caching Stage ---
FROM chef as cache
WORKDIR /app
RUN apt-get update -y && apt-get install -y \
libssl-dev \
ca-certificates \
libudev-dev \
libusb-1.0-0-dev \
pkg-config \
libudev-dev \
build-essential
COPY --from=chef /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# --- Application Build Stage ---
FROM cache as builder
WORKDIR /app
RUN apt-get update -y && apt-get install -y \
libssl-dev \
ca-certificates \
libudev-dev \
libusb-1.0-0-dev \
pkg-config \
libudev-dev \
build-essential
COPY . .
COPY --from=cache /app/target target
ENV SQLX_OFFLINE=true
RUN cargo build --release
# --- Final Stage with Minimal Base Image ---
FROM debian:bookworm-slim
RUN apt-get update -y && apt-get install -y \
libssl-dev \
ca-certificates \
libudev-dev \
libusb-1.0-0-dev \
pkg-config \
libudev-dev \
build-essential
RUN useradd -ms /bin/bash app
USER app
WORKDIR /app
COPY --from=builder /app/target/release/devhub-cache-api .
COPY --from=builder /app/Rocket.toml .
EXPOSE 8080
CMD ["./devhub-cache-api"]