-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApi.Dockerfile
36 lines (34 loc) · 1.01 KB
/
Api.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
FROM rust:1.65-bullseye AS chef
RUN cargo install cargo-chef
FROM chef AS planner
COPY das_api /rust/das_api/
WORKDIR /rust/das_api
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
RUN apt-get update -y && \
apt-get install -y build-essential make git
COPY digital_asset_types /rust/digital_asset_types
WORKDIR /
RUN mkdir -p /rust/das_api
WORKDIR /rust/das_api
COPY --from=planner /rust/das_api/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
COPY das_api/Cargo.toml .
COPY das_api .
# Build application
RUN cargo build --release
FROM rust:1.65-slim-bullseye
ARG APP=/usr/src/app
RUN apt update \
&& apt install -y curl ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*
ENV TZ=Etc/UTC \
APP_USER=appuser
RUN groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP}
COPY --from=builder /rust/das_api/target/release/das_api ${APP}
RUN chown -R $APP_USER:$APP_USER ${APP}
USER $APP_USER
WORKDIR ${APP}
CMD /usr/src/app/das_api