-
Notifications
You must be signed in to change notification settings - Fork 89
/
Dockerfile
46 lines (38 loc) · 1.42 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
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
RUN apt-get update && apt-get install -y musl-tools musl-dev
RUN update-ca-certificates
WORKDIR /app
FROM node:20-alpine as web-builder
WORKDIR /app
COPY web/package.json .
RUN npm install
COPY web .
RUN npm run build
FROM chef AS planner
COPY server .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS app-builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --profile dist --recipe-path recipe.json
COPY server .
RUN rustup target add x86_64-unknown-linux-musl
RUN cargo build --profile dist --bin displex --target x86_64-unknown-linux-musl
# taken from https://medium.com/@lizrice/non-privileged-containers-based-on-the-scratch-image-a80105d6d341
FROM ubuntu:latest as user-creator
RUN groupadd -g 1001 displex \
&& useradd -u 1001 -g 1001 displex \
&& mkdir /data \
&& chown -R displex:displex /data
FROM scratch AS runtime
COPY --from=user-creator /etc/passwd /etc/passwd
COPY --from=user-creator --chown=displex:displex /data /data
VOLUME [ "/data" ]
WORKDIR /data
USER displex
ENV RUST_LOG="displex=info,sea_orm=info" \
DISPLEX_HTTP__HOST=0.0.0.0 \
DISPLEX_HTTP__PORT=8080 \
DATABASE_URL=sqlite://displex.db?mode=rwc
COPY --from=app-builder --chown=displex:displex /app/target/x86_64-unknown-linux-musl/dist/displex /displex
COPY --from=web-builder --chown=displex:displex /app/dist /dist
ENTRYPOINT ["/displex"]