FROM node:22-alpine AS build WORKDIR /app # Native modules (better-sqlite3, ssh2, node-pty) need a toolchain to compile. RUN apk add --no-cache python3 make g++ COPY package.json package-lock.json* ./ RUN npm install --omit=dev=false COPY . . RUN npm run build FROM node:22-alpine WORKDIR /app ENV NODE_ENV=production # Toolchain is needed again here: production deps are reinstalled fresh, and the # native modules (better-sqlite3, ssh2, node-pty) compile from source on install. RUN apk add --no-cache python3 make g++ COPY package.json package-lock.json* ./ RUN npm install --omit=dev COPY --from=build /app/dist ./dist EXPOSE 4000 CMD ["node", "dist/server.js"]