-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (34 loc) · 1.12 KB
/
Copy pathDockerfile
File metadata and controls
46 lines (34 loc) · 1.12 KB
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
# START -- Rust backend builder
FROM rust:1.87.0-alpine3.21 AS rust-builder-chef
RUN apk add --no-cache musl-dev gcc libc-dev curl
RUN cargo install --version 0.1.71 cargo-chef
WORKDIR /app
FROM rust-builder-chef AS rust-planner
COPY /backend .
RUN cargo chef prepare --recipe-path recipe.json
FROM rust-builder-chef AS rust-builder
COPY --from=rust-planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY /backend .
RUN SQLX_OFFLINE=true cargo build --release
# END -- Rust backend builder
# START -- React frontend builder
FROM node:22.15.1-alpine3.21 AS react-base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY /frontend /app
WORKDIR /app
FROM react-base AS react-builder
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
ARG VITE_VERSION
ARG VITE_COMMIT_SHA
ENV VITE_VERSION=${VITE_VERSION}
ENV VITE_COMMIT_SHA=${VITE_COMMIT_SHA}
RUN pnpm run build
# END -- React frontend builder
FROM scratch AS final
COPY --from=rust-builder /app/target/release/backend /
COPY --from=react-builder /app/dist /dist
EXPOSE 3000
CMD [ "/backend" ]