-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (51 loc) · 2.38 KB
/
Dockerfile
File metadata and controls
72 lines (51 loc) · 2.38 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
# Stage 1: Build the web server binary
FROM rust:1.85-bookworm AS builder
WORKDIR /app
# Copy workspace manifests first for dependency caching
COPY Cargo.toml Cargo.lock ./
COPY crates/git-kanban-core/Cargo.toml crates/git-kanban-core/Cargo.toml
COPY crates/git-kanban-web/Cargo.toml crates/git-kanban-web/Cargo.toml
COPY crates/git-kanban-tui/Cargo.toml crates/git-kanban-tui/Cargo.toml
# Create dummy source files so cargo can resolve the workspace and cache deps
RUN mkdir -p crates/git-kanban-core/src && echo "pub fn _dummy() {}" > crates/git-kanban-core/src/lib.rs \
&& mkdir -p crates/git-kanban-web/src && echo "fn main() {}" > crates/git-kanban-web/src/main.rs \
&& mkdir -p crates/git-kanban-tui/src && echo "fn main() {}" > crates/git-kanban-tui/src/main.rs
# Build dependencies only (cached unless Cargo.toml changes)
RUN cargo build --release -p git-kanban-web 2>/dev/null || true
# Copy real source code and migrations
COPY crates/git-kanban-core/src crates/git-kanban-core/src
COPY crates/git-kanban-web/src crates/git-kanban-web/src
COPY crates/git-kanban-tui/src crates/git-kanban-tui/src
COPY migrations migrations
# Touch source files to invalidate cached compilation (not the deps)
RUN touch crates/git-kanban-core/src/lib.rs crates/git-kanban-web/src/main.rs
# Build the web server
RUN cargo build --release -p git-kanban-web
# Stage 2: Build the Yew WASM frontend
FROM rust:1.85-bookworm AS frontend
RUN rustup target add wasm32-unknown-unknown \
&& cargo install trunk
WORKDIR /app/crates/git-kanban-frontend
COPY crates/git-kanban-frontend/ .
RUN trunk build --release
# Stage 3: Minimal runtime image
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --shell /bin/bash kanban
USER kanban
WORKDIR /home/kanban
# Copy the compiled binary
COPY --from=builder /app/target/release/git-kanban-web .
# Copy the frontend dist
COPY --from=frontend /app/crates/git-kanban-frontend/dist crates/git-kanban-frontend/dist
# Copy migrations (embedded by sqlx, but include for reference)
COPY --from=builder /app/migrations migrations
ENV GITHUB_TOKEN=""
ENV DATABASE_URL="sqlite:git-kanban.db?mode=rwc"
ENV GIT_KANBAN_HOST="0.0.0.0"
ENV GIT_KANBAN_PORT="3000"
ENV RUST_LOG="git_kanban_web=info,git_kanban_core=info"
EXPOSE 3000
CMD ["./git-kanban-web"]