-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (29 loc) · 844 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
# thanks https://whitfin.io/speeding-up-rust-docker-builds/
# select build image
FROM rust:bookworm as build
# create a new empty shell project
RUN USER=root cargo new --bin bottle
WORKDIR /bottle
# copy over your manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
# this build step will cache your dependencies
RUN cargo build --release
RUN rm src/*.rs
# copy your source tree
COPY ./src ./src
# copy migrations
COPY ./migrations ./migrations
# build for release
RUN touch src/main.rs && cargo build --release
# our final base
FROM rust:bookworm
WORKDIR /bottle
RUN apt install libpq-dev
# copy the build artifact from the build stage
COPY --from=build /bottle/target/release/bottle ./bottle
# copy res & .env
COPY ./res ./res
COPY "./.env" "./.env"
# set the startup command to run your binary
CMD ["./bottle"]