forked from cea-sec/openwec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (41 loc) · 1.27 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
FROM rust:slim-bookworm as chef
RUN cargo install cargo-chef
WORKDIR /SRC
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
# Install system deps
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
libssl-dev \
libkrb5-dev \
make \
pkgconf
COPY --from=planner /SRC/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release --locked
FROM debian:bookworm-slim
ARG APP=/usr/src/openwec
ARG DATA=/var/lib/openwec/data
ARG DB=/var/lib/openwec/db
EXPOSE 5985
ENV APP_USER=openwec
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
libgssapi-krb5-2 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP} ${DATA} ${DB}
COPY --from=builder /SRC/target/release/openwec ${APP}/openwec
COPY --from=builder /SRC/target/release/openwecd ${APP}/openwecd
COPY ./docker/entrypoint.sh ${APP}/entrypoint.sh
RUN chown -R $APP_USER:$APP_USER ${APP} ${DATA} ${DB}
USER $APP_USER
WORKDIR ${APP}
CMD ["./entrypoint.sh"]