-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (24 loc) · 922 Bytes
/
Dockerfile
File metadata and controls
33 lines (24 loc) · 922 Bytes
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
FROM node:20-alpine AS frontend-builder
WORKDIR /app
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ .
ARG VITE_API_PATH=/api
ENV VITE_API_PATH=${VITE_API_PATH}
RUN npm run build
FROM rust:1.89 AS backend-builder
WORKDIR /usr/src/app
COPY backend/Cargo.toml Cargo.toml
COPY backend/Cargo.lock Cargo.lock
# Create dummy src to build dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
# Copy actual source and rebuild (only recompiles app code, not dependencies)
COPY backend/src/ src/
RUN touch src/main.rs && cargo build --release
# Stage 3: Runtime
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=backend-builder /usr/src/app/target/release/cm-api-rs /usr/local/bin/cm-api-rs
COPY --from=frontend-builder /app/dist /var/www/static
CMD ["cm-api-rs"]