-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
36 lines (26 loc) · 954 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
# Build stage
FROM ekidd/rust-musl-builder:latest AS builder
RUN mkdir -p /home/rust/database_backend
WORKDIR /home/rust/database_backend
VOLUME ["/home/rust/databasebackend"]
# cache dependency artifacts. 'Cargo build' builds
# both dependencies and project files,
# splitting the project into dependencies with single
# empty main and current project sources.
COPY --chown=rust:rust Cargo.toml Cargo.toml
COPY --chown=rust:rust Cargo.lock Cargo.lock
RUN mkdir -p src
RUN echo 'fn main() {}' > src/main.rs
RUN cargo build --release
# build the project using prebuilt deps
RUN rm /home/rust/database_backend/src/main.rs
COPY --chown=rust:rust ./src ./src
RUN mkdir data
RUN cargo build --release
FROM scratch
COPY data/collected.txt data/data.txt
COPY --from=builder \
/home/rust/database_backend/target/x86_64-unknown-linux-musl/release/database_backend \
/usr/local/bin/
EXPOSE 8080/tcp
ENTRYPOINT ["/usr/local/bin/database_backend"]