-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (44 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
55 lines (44 loc) · 1.3 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
47
48
49
50
51
52
53
54
55
# Stage 1: Build Frontend
FROM node:24-alpine AS frontend-builder
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy package files
COPY frontend/package.json frontend/pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source code and build
COPY frontend/ .
RUN pnpm build
# Stage 2: Build Backend
FROM rust:alpine AS backend-builder
WORKDIR /app
# Install musl-dev for static linking
RUN apk add --no-cache musl-dev
# Create a dummy project to cache dependencies
RUN cargo new backend
WORKDIR /app/backend
COPY backend/Cargo.toml backend/Cargo.lock ./
# Build dependencies only
RUN cargo build --release
# Copy actual source code
COPY backend/src ./src
# Touch main.rs to force rebuild of the application
# Remove the fingerprint of the dummy build to ensure full rebuild of the bin
RUN touch src/main.rs
ARG APP_VERSION
RUN APP_VERSION=${APP_VERSION} cargo build --release
# Stage 3: Runtime
FROM alpine:latest
WORKDIR /app
# Install necessary runtime dependencies (if any)
RUN apk add --no-cache ca-certificates tzdata
# Copy backend binary
COPY --from=backend-builder /app/backend/target/release/rust-sqlite-webui .
# Copy frontend assets
COPY --from=frontend-builder /app/dist ./dist
# Environment variables
ENV RUST_LOG=info
ENV PORT=3000
EXPOSE 3000
CMD ["./rust-sqlite-webui"]