-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (27 loc) · 845 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
# Rust as the base image
FROM rust:1.68 as build
# Create a new empty shell project
RUN USER=root cargo new --bin rust-backend-stack
WORKDIR /rust-backend-stack
# Copy our manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./sqlx-data.json ./sqlx-data.json
COPY ./migrations ./migrations
# TODO find a way to skip this
COPY ./tests ./tests
# Build only the dependencies to cache them
RUN cargo build --release
RUN rm src/*.rs
# Copy the source code
COPY ./src ./src
# Build for release.
RUN rm ./target/release/deps/rust_backend_stack*
RUN cargo build --release
# TODO use a smaller image
# The final base image
FROM rust:1.68
# Copy from the previous build
COPY --from=build /rust-backend-stack/target/release/rust-backend-stack /usr/src/rust-backend-stack
# Run the binary
CMD ["/usr/src/rust-backend-stack"]