-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (43 loc) · 1.29 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (43 loc) · 1.29 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
56
57
58
59
60
61
62
63
# Stage 1: Build UI
FROM node:22-slim AS ui-builder
WORKDIR /app/ui
# Copy manifests first for better caching
COPY ui/package.json ui/package-lock.json ./
# Install dependencies
RUN npm ci
# Copy UI source
COPY ui/ ./
# Build the UI
RUN npm run build
# Stage 2: Build Rust binary
FROM rust:latest AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy manifests first for better caching
COPY Cargo.toml Cargo.lock ./
# Create dummy src to build dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Build dependencies only
RUN cargo build --release && rm -rf src
# Copy actual source code
COPY src ./src
# Build the actual binary
RUN touch src/main.rs && cargo build --release
# Stage 3: Runtime (same base as builder for glibc compatibility)
FROM debian:trixie-slim
# Install runtime dependencies for TLS
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3t64 \
&& rm -rf /var/lib/apt/lists/*
# Copy binary from builder
COPY --from=builder /app/target/release/laws /usr/local/bin/laws
# Copy UI dist from ui-builder
COPY --from=ui-builder /app/ui/dist /usr/local/share/laws/ui/dist
WORKDIR /usr/local/share/laws
EXPOSE 4566
ENTRYPOINT ["laws"]