-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (33 loc) · 1.18 KB
/
Dockerfile
File metadata and controls
41 lines (33 loc) · 1.18 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
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies
RUN apt-get update
RUN apt-get install musl-tools -y
RUN rustup target add x86_64-unknown-linux-musl
ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc"
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
# Build application
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./src ./src
COPY ./.sqlx ./.sqlx
COPY ./migrations ./migrations
RUN apt-get update
RUN apt-get install musl-tools -y
ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc"
RUN cargo build --release --target x86_64-unknown-linux-musl
# Test without smaller image
ENV RUST_BACKTRACE="full"
ENTRYPOINT [ "/app/target/x86_64-unknown-linux-musl/release/dd_rpc" ]
# Create a minimal image with the compiled binary
#FROM gcr.io/distroless/static AS runtime
#FROM scratch
# FROM debian:bookworm-slim
# WORKDIR /app
# COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc
#ENTRYPOINT ["/app/dd_rpc"]