forked from RightNow-AI/openfang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (68 loc) · 2.49 KB
/
Dockerfile
File metadata and controls
75 lines (68 loc) · 2.49 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
75
# syntax=docker/dockerfile:1
# ── Stage 1: Install cargo-chef ──────────────────────────────────────────────
FROM rust:1-slim-bookworm AS chef
RUN apt-get update && apt-get install -y \
pkg-config libssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN cargo install cargo-chef --locked
WORKDIR /build
# ── Stage 2: Prepare recipe (dependency lockfile) ────────────────────────────
FROM chef AS planner
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY xtask ./xtask
COPY agents ./agents
COPY packages ./packages
# Exclude desktop crate (Tauri) — requires GTK/GDK/libsoup headers not needed for server
RUN sed -i '/"crates\/openfang-desktop"/d' Cargo.toml
RUN cargo chef prepare --recipe-path recipe.json
# ── Stage 3: Cook dependencies (CACHED between deploys) ─────────────────────
FROM chef AS builder
COPY --from=planner /build/recipe.json recipe.json
ARG LTO=true
ARG CODEGEN_UNITS=1
ENV CARGO_PROFILE_RELEASE_LTO=${LTO} \
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${CODEGEN_UNITS}
RUN cargo chef cook --release --recipe-path recipe.json
# ── Stage 4: Build application (only YOUR code, ~30s) ───────────────────────
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY xtask ./xtask
COPY agents ./agents
COPY packages ./packages
# Same exclusion for the actual build
RUN sed -i '/"crates\/openfang-desktop"/d' Cargo.toml
RUN cargo build --release --bin openfang
# ── Stage 5: Runtime image ──────────────────────────────────────────────────
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-venv \
nodejs \
npm \
chromium \
fonts-liberation \
libnss3 \
libatk-bridge2.0-0 \
libdrm2 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libasound2 \
libpango-1.0-0 \
libcairo2 \
libcups2 \
libxss1 \
libgtk-3-0 \
&& rm -rf /var/lib/apt/lists/*
ENV CHROME_PATH=/usr/bin/chromium
COPY --from=builder /build/target/release/openfang /usr/local/bin/
COPY --from=builder /build/agents /opt/openfang/agents
EXPOSE 4200
VOLUME /data
ENV OPENFANG_HOME=/data
ENTRYPOINT ["openfang"]
CMD ["start"]