-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
36 lines (26 loc) · 900 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
FROM rust:1.76-bookworm as build
# create a new empty shell project
RUN USER=root cargo new --bin drinks-accounting
WORKDIR /drinks-accounting
# copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
# this build step will cache the dependencies
RUN cargo build --release
RUN rm src/*.rs
# copy your source tree
COPY ./migrations ./migrations
COPY ./src ./src
COPY ./.sqlx ./.sqlx
# build for release
RUN touch src/main.rs
# sqlx should not check sql queries when building for production
ENV SQLX_OFFLINE true
RUN cargo build --release
# our final base
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
# copy the build artifact from the build stage
COPY --from=build /drinks-accounting/target/release/drinks-accounting /
# set the startup command to run your binary
CMD ["/drinks-accounting"]