-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Dockerfile
55 lines (47 loc) · 1.47 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
54
55
FROM node:20-alpine as web
WORKDIR /app
COPY web/package.json web/pnpm-lock.yaml web/.npmrc .
RUN npm i -g pnpm
RUN pnpm install --ignore-scripts --frozen-lockfile
COPY web/ .
RUN pnpm run generate-translation-types
RUN pnpm build
FROM rust:1.80 as chef
WORKDIR /build
# install & cache necessary components
RUN cargo install cargo-chef
RUN rustup component add rustfmt
FROM chef as planner
# prepare recipe
COPY Cargo.toml Cargo.lock ./
COPY src src
COPY model-derive model-derive
COPY proto proto
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
# build deps from recipe & cache as docker layer
COPY --from=planner /build/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# build project
COPY --from=web /app/dist ./web/dist
COPY web/src/shared/images/svg ./web/src/shared/images/svg
COPY user_agent_header_regexes.yaml /build/user_agent_header_regexes.yaml
RUN apt-get update && apt-get -y install protobuf-compiler libprotobuf-dev
COPY Cargo.toml Cargo.lock build.rs ./
# for vergen
COPY .git .git
COPY .sqlx .sqlx
COPY src src
COPY templates templates
COPY model-derive model-derive
COPY proto proto
COPY migrations migrations
RUN cargo install --locked --path . --root /build
# run
FROM debian:bookworm-slim as runtime
RUN apt-get update -y && \
apt-get install --no-install-recommends -y ca-certificates libssl-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /build/bin/defguard .
ENTRYPOINT ["./defguard"]