-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
31 lines (30 loc) · 926 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
FROM rust:slim-bullseye as build
# create a new empty shell project
RUN USER=root cargo new --bin forum
WORKDIR /forum
# copy 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 source tree
COPY ./src ./src
# copy sqlx offline data
COPY ./sqlx-data.json ./sqlx-data.json
# copy db migrations
COPY ./migrations ./migrations
# build for release
RUN rm ./target/release/deps/forum*
RUN cargo build --release
# our final base
FROM debian:bullseye-slim
# copy the build artifact from the build stage
COPY --from=build /forum/target/release/forum .
# copy static files and templates
COPY ./templates ./templates
COPY ./static ./static
# copy rocket configuration file
COPY ./Rocket.toml ./Rocket.toml
# set the startup command to run the binary
CMD ["./forum"]