-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (56 loc) · 2.23 KB
/
Copy pathDockerfile
File metadata and controls
59 lines (56 loc) · 2.23 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
# Single-container production image: the Hono backend serves both the built
# frontend (frontend/dist) and the /api/* routes. Build context is the repo
# ROOT (it needs both frontend/ and backend/).
#
# Local dev is unaffected — developers still run the Vite dev-server and
# `npm run dev` separately. This image is a deploy concern only.
# 1) Build the frontend -> /frontend/dist (Vite). Includes the Google Docs
# sidebar bundle (dist/google-docs.bundle.js), same as the old frontend image.
FROM node:24-slim AS frontend
WORKDIR /frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build && npm run build:google-docs
# 2) Build the backend -> /app/backend/dist (tsc).
FROM node:24-slim AS backend
WORKDIR /app/backend
COPY backend/package.json backend/package-lock.json* ./
RUN npm install
COPY backend/tsconfig.json ./
COPY backend/src ./src
RUN npm run build
# 3) Runtime: Node serving the compiled backend + the frontend as static files.
FROM node:24-slim AS run
WORKDIR /app/backend
ENV NODE_ENV=production
# Debug tools for shelling into a running/deployed container.
RUN apt-get update && apt-get install -y --no-install-recommends \
sqlite3 \
less \
curl \
ca-certificates \
vim \
jq \
htop \
procps \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*
# Surfaced by GET /api/ping (backend/src/config.ts) so a deployed container can
# be traced back to the commit it was built from.
ARG GIT_COMMIT=unknown
ENV GIT_COMMIT=${GIT_COMMIT}
# STATIC_ROOT (backend/src/static.ts) defaults to ./public; DATA_DIR
# (backend/src/config.ts) defaults to ./data but compose points it at the
# mounted data volume.
COPY backend/package.json backend/package-lock.json* ./
RUN npm install --omit=dev
COPY --from=backend /app/backend/dist ./dist
# Frontend build output becomes the static root (STATIC_ROOT=./public).
COPY --from=frontend /frontend/dist ./public
# The Apps Script sidebar loads the Google Docs bundle by absolute URL at
# /gdocs/google-docs.bundle.js (its PROD_BASE points there), so expose it at
# that path in addition to the dist root.
COPY --from=frontend /frontend/dist/google-docs.bundle.js ./public/gdocs/google-docs.bundle.js
EXPOSE 5000
CMD ["node", "dist/index.js"]