-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
51 lines (43 loc) · 1.28 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
FROM node:20-alpine as web
WORKDIR /app
COPY web/package.json .
COPY web/pnpm-lock.yaml .
COPY 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 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
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 src src
COPY proto proto
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 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /build/bin/defguard-proxy .
ENTRYPOINT ["./defguard-proxy"]