-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (59 loc) · 1.86 KB
/
Dockerfile
File metadata and controls
74 lines (59 loc) · 1.86 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
64
65
66
67
68
69
70
71
72
73
74
# Dependency planner stage
FROM lukemathwalker/cargo-chef:latest-rust-1.93.0-slim AS chef
WORKDIR /app
FROM chef AS planner
COPY Cargo.toml Cargo.lock ./
COPY dwctl/ dwctl/
RUN cargo chef prepare --recipe-path recipe.json
# Backend build stage
FROM chef AS builder
# Install build dependencies including Node.js
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g pnpm@10
# Build dependencies (cached unless Cargo.toml/Cargo.lock change)
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Build frontend
COPY dashboard/package.json dashboard/pnpm-lock.yaml dashboard/
WORKDIR /app/dashboard
RUN pnpm install --frozen-lockfile
COPY dashboard/ /app/dashboard/
RUN pnpm run build
WORKDIR /app
# Copy source and build
COPY .sqlx/ .sqlx/
COPY Cargo.toml Cargo.lock ./
COPY dwctl/ dwctl/
RUN rm -rf dwctl/static && cp -r dashboard/dist dwctl/static
ENV SQLX_OFFLINE=true
RUN cargo build --release -p dwctl
# Runtime stage
FROM ubuntu:24.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
libxml2 \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy the binary from builder stage (frontend is already embedded in the binary)
COPY --from=builder /app/target/release/dwctl /app/dwctl
# Copy default email templates (can be overridden via volume mount)
COPY dwctl/default_templates/ /app/default_templates/
# Change ownership of the app directory to the ubuntu user
RUN chown -R ubuntu:ubuntu /app
# Switch to non-root user
USER ubuntu
# Expose port (app uses 3001 by default)
EXPOSE 3001
# Run the application
ENTRYPOINT ["./dwctl"]
CMD []