Files
remote-control-support-webapp/Dockerfile
T
rmancinasandClaude Opus 5 cecaf74a0a
Build and Deploy Remote Control Support / Test (push) Successful in 10s
Build and Deploy Remote Control Support / Build Image (push) Successful in 37s
Build and Deploy Remote Control Support / Deploy to Portainer (push) Successful in 6s
feat(agent): ship a Node 12 executable for Windows Server 2008 R2
Machines that cannot install Node 22 had no way to run the agent at all, which
left them stuck on direct mode — and direct mode only works when the hub can
route to the VNC port, which it often cannot.

agent.js now resolves the two Node 22 globals it uses through fallbacks: `ws`
for the control and tunnel sockets, and http/https for the single enrolment
POST. Node 22 loads neither, since `globalThis.WebSocket || require('ws')`
short-circuits. The require and the http/https references are static so the
bundler can follow them.

A new Docker stage bundles that file with a Node 12 runtime — the last line
supporting Windows 7 and Server 2008 R2 — into one self-contained .exe, served
from /download/agent.exe and linked from the enrolment page. The route answers
503 rather than 404 in a dev checkout, where the build has not run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-12 00:55:57 -07:00

40 lines
1.2 KiB
Docker

# Machines that cannot run Node 22 still need an agent. Windows Server 2008 R2
# and Windows 7 top out at Node 13, so the same agent.js is bundled with a Node
# 12 runtime into a single .exe the hub serves from /download/agent.exe.
FROM node:22-alpine AS agent-exe
WORKDIR /build
COPY agent ./agent
# `ws` stands in for the global WebSocket the old runtime does not have; pkg
# follows the literal require in agent.js and bundles it.
RUN npm install --no-save --no-audit --no-fund ws@8.18.0 \
&& npx --yes pkg@5.8.1 agent/agent.js \
--targets node12-win-x64 \
--output dist/rcs-agent.exe
FROM node:22-alpine
# node:sqlite is built into Node 22, so there are no native modules to compile
# and no build stage to carry around.
ENV NODE_ENV=production \
PORT=8080 \
DB_PATH=/data/rcs.db
WORKDIR /app
RUN corepack enable
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml* ./
RUN pnpm install --prod --frozen-lockfile
COPY server ./server
COPY public ./public
COPY agent ./agent
COPY --from=agent-exe /build/dist/rcs-agent.exe ./dist/rcs-agent.exe
VOLUME ["/data"]
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
CMD wget -qO- http://127.0.0.1:8080/api/health || exit 1
CMD ["node", "server/index.js"]