-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.backend
More file actions
42 lines (35 loc) · 2.15 KB
/
Copy pathDockerfile.backend
File metadata and controls
42 lines (35 loc) · 2.15 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
# ── ChainForge Express Backend ─────────────────────────────────────────────────
#
# Directory layout inside the container:
# /app/backend/ ← backend code (server.js, node_modules, etc.) — __dirname
# /go-root/ ← GO_ROOT env var — where the Go binary reads/writes
# blockchain_<NODE_ID>.db / wallet_<NODE_ID>.dat.
# chain-data volume is mounted here in docker-compose.
# /go-bin/ ← shared volume from go-builder
# chainforge ← Linux binary copied here by go-builder
#
# IMPORTANT: backend code must NOT live inside /go-root (or any path under the
# chain-data mount point). Mounting a named volume REPLACES everything the
# image had at that path — it does not merge with it. Once the volume has data
# in it (after its first use), any code baked into a later image build at that
# same path is silently hidden behind the volume's older snapshot. That's why
# GO_ROOT is resolved from an explicit env var (see goRunner.js) instead of
# being derived from __dirname like it used to be.
#
# At startup the CMD copies /go-bin/chainforge → /usr/local/bin/chainforge.exe
# so server.js can call `chainforge.exe` from any cwd and it resolves on PATH.
# ──────────────────────────────────────────────────────────────────────────────
FROM node:20-alpine
WORKDIR /app/backend
# Install dependencies
COPY backend/package.json backend/package-lock.json* ./
RUN npm install --omit=dev
# Copy backend source (server.js, db.js, goRunner.js, models/, routes/, etc.)
COPY backend/ ./
ENV GO_ROOT=/go-root
EXPOSE 5000
# At startup:
# 1. Copy the Go binary from the shared go-bin volume to /usr/local/bin
# named chainforge.exe so server.js execSync(`chainforge.exe ...`) works.
# 2. Start the Node server.
CMD ["sh", "-c", "cp /go-bin/chainforge /usr/local/bin/chainforge.exe && chmod +x /usr/local/bin/chainforge.exe && node server.js"]