-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (32 loc) · 1001 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
41
42
#stage 1 - generate a recipe file for dependencies
FROM rust as planner
WORKDIR /app
RUN cargo install cargo-chef
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
#stage 2 - build dependencies
FROM rust as cacher
WORKDIR /app
RUN cargo install cargo-chef
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
#stage 3 - build the app
FROM rust as builder
#copy the app into the docker image
COPY . /app
# set the working directory
WORKDIR /app
#copy the dependencies from the cacher stage
COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
#build the app
RUN cargo build --release
# use google's distroless image as the base image
FROM gcr.io/distroless/cc-debian11
WORKDIR /app
# copy the binary from the builder stage
COPY --from=builder /app/target/release/blockchain-asset-querier /app/blockchain-asset-querier
EXPOSE 8080
EXPOSE 8081
# run the binary
CMD ["./blockchain-asset-querier"]