-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile.web
More file actions
51 lines (45 loc) · 2.4 KB
/
Copy pathDockerfile.web
File metadata and controls
51 lines (45 loc) · 2.4 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
# c0mpute.com — single Railway deploy (DIP-0014).
#
# One service, two co-located processes: the Next.js site (foreground) and the
# status aggregator (Rust libp2p observer, background). The site proxies
# /status + /api/status to the aggregator over loopback. This replaces the
# earlier separate `c0mpute-status-aggregator` Railway service — the whole
# monorepo ships as one deploy.
#
# Point the c0mpute.com service at this file with the RAILWAY_DOCKERFILE_PATH
# variable (= Dockerfile.web). Build context is the repo root.
# ── stage 1: build the aggregator (Rust) ─────────────────────────────────
# Copy only the Rust workspace so edits under apps/web/ don't bust this layer.
FROM rust:1.92-bookworm AS rustbuild
WORKDIR /src
COPY Cargo.toml Cargo.lock ./
COPY node ./node
RUN cargo build --release --bin c0mpute
# ── stage 2: build the Next.js site (Bun) ────────────────────────────────
FROM oven/bun:1.3-debian AS webbuild
WORKDIR /app
# Native deps (better-sqlite3 is an optional native module) need a toolchain.
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY . .
RUN bun install --frozen-lockfile
RUN bun run --cwd packages/shared build && bun run --filter=c0mpute build
# ── stage 3: runtime ─────────────────────────────────────────────────────
FROM oven/bun:1.3-debian AS runtime
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Full built app: `next start` (non-standalone) serves from .next, and several
# route handlers read repo files at request time (scripts/install.sh, etc.),
# so the whole tree + node_modules must be present.
COPY --from=webbuild /app /app
# Co-located aggregator binary.
COPY --from=rustbuild /src/target/release/c0mpute /usr/local/bin/c0mpute
COPY scripts/railway-web-start.sh /usr/local/bin/railway-web-start.sh
RUN chmod +x /usr/local/bin/railway-web-start.sh
# The aggregator serves its JSON on loopback; the site reads it there.
ENV C0MPUTE_STATUS_BIND=127.0.0.1:8090
ENV STATUS_AGGREGATOR_URL=http://127.0.0.1:8090
ENTRYPOINT ["/usr/local/bin/railway-web-start.sh"]