Repository navigation
Expand file tree
/
Copy pathDockerfile.backend
More file actions
90 lines (75 loc) · 3.91 KB
/
Copy pathDockerfile.backend
File metadata and controls
90 lines (75 loc) · 3.91 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# ============================================
# Jet Admin - Backend Container
# ============================================
# Node.js API server
FROM node:20-slim
# Install system dependencies (nginx = reverse proxy in front of Node,
# gettext-base = envsubst for rendering nginx.backend.conf at startup)
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-client \
openssl \
netcat-openbsd \
wget \
nginx \
gettext-base \
python3 \
g++ \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /etc/nginx/sites-enabled/default /etc/nginx/conf.d/default.conf
WORKDIR /app
# Copy root package files (for workspace resolution)
COPY package*.json ./
# Copy workspace package.json files — ALL packages, not just the ones the
# backend imports. npm only installs (and links bins for) workspace members
# visible at install time; packages built later via build:packages need
# their own nested binaries (esbuild versions differ per package, so npm
# nests instead of hoisting — there is no usable root .bin/esbuild).
COPY apps/backend/package*.json ./apps/backend/
COPY packages/datasource-types/package*.json ./packages/datasource-types/
COPY packages/datasources-logic/package*.json ./packages/datasources-logic/
COPY packages/datasources-ui/package*.json ./packages/datasources-ui/
COPY packages/expression-engine/package*.json ./packages/expression-engine/
COPY packages/json-forms-renderers/package*.json ./packages/json-forms-renderers/
COPY packages/mcp-server/package*.json ./packages/mcp-server/
COPY packages/ui/package*.json ./packages/ui/
COPY packages/widget-types/package*.json ./packages/widget-types/
COPY packages/widgets-logic/package*.json ./packages/widgets-logic/
COPY packages/widgets-ui/package*.json ./packages/widgets-ui/
COPY packages/workflow-edges/package*.json ./packages/workflow-edges/
COPY packages/workflow-nodes/package*.json ./packages/workflow-nodes/
COPY packages/workflow-nodes-logic/package*.json ./packages/workflow-nodes-logic/
# Install dependencies (includes devDependencies — package builds need esbuild)
RUN npm install --legacy-peer-deps
# Copy source files
COPY apps/backend/ ./apps/backend/
COPY packages/ ./packages/
COPY scripts/build-packages.js ./scripts/build-packages.js
# Build workspace packages (entry points resolve to dist/, which is excluded
# from the build context via .dockerignore and never committed to git)
RUN npm run build:packages
# Backend nginx reverse-proxy template (rendered by the entrypoint via
# envsubst into /etc/nginx/nginx.conf; see docker-entrypoint.backend.sh).
# nginx listens on $NGINX_PORT (compose: 3000, Render: $PORT) and proxies to
# Node.js on 127.0.0.1:$NODE_PORT (entrypoint exports PORT=$NODE_PORT).
COPY nginx.backend.conf /etc/nginx/nginx.conf.template
# Generate Prisma client
WORKDIR /app/apps/backend
RUN npx prisma generate
# Copy entrypoint script
COPY docker-entrypoint.backend.sh /entrypoint.sh
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
# Create log directory (Node + nginx file logs live here, persisted via the
# backend_logs volume in compose)
RUN mkdir -p /app/apps/backend/logs /var/cache/nginx /var/log/nginx \
&& chmod 755 /app/apps/backend/logs \
&& chown -R www-data:www-data /app/apps/backend/logs /var/cache/nginx /var/log/nginx
# Nginx public port inside the container (compose maps host 8090 -> 3000).
# Render injects $PORT at runtime — the entrypoint remaps it to $NGINX_PORT.
EXPOSE 3000
# Health check — hits nginx (public port resolved by the entrypoint into
# /tmp/nginx_port; falls back to NGINX_PORT/3000), which proxies /health to
# Node. Verifies the full proxy chain, not just the Node process.
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD sh -c 'wget --no-verbose --tries=1 --spider http://localhost:$(cat /tmp/nginx_port 2>/dev/null || echo ${NGINX_PORT:-3000})/health || exit 1'
ENTRYPOINT ["/entrypoint.sh"]
CMD ["npm", "run", "pm2"]