fix(orbit): fix multi-stage Dockerfile syntax for pack-static builds

COPY instructions cannot use shell redirects (2>/dev/null).
Replace with a RUN step that copies built output (dist/build/public/out)
to a clean /output dir, then single COPY --from=builder /output → nginx.
Also use node:22-alpine for Node.js >= 22 compatibility (h5bp, modern SPAs).
This commit is contained in:
2026-10-14 17:30:35 +05:30
parent 5f4730b8d0
commit 745e69f042
+11 -9
View File
@@ -323,21 +323,23 @@ CMD ["npm", "start"]
} }
var dockerfile string var dockerfile string
if buildCmd != "" { if buildCmd != "" {
// Multi-stage: build then serve with nginx // Multi-stage: build with Node then serve with nginx
// Use a RUN step to move built output to /output dir, then COPY that in nginx stage
dockerfile = `FROM node:22-alpine AS builder dockerfile = `FROM node:22-alpine AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm install --legacy-peer-deps 2>/dev/null || npm install || true RUN npm install --legacy-peer-deps 2>/dev/null || npm install 2>/dev/null || true
COPY . . COPY . .
RUN npm run build 2>/dev/null || true RUN npm run build 2>/dev/null || true
RUN mkdir -p /output && \
if [ -d dist ] && [ "$(ls -A dist)" ]; then cp -r dist/. /output/; \
elif [ -d build ] && [ "$(ls -A build)" ]; then cp -r build/. /output/; \
elif [ -d public ] && [ "$(ls -A public)" ]; then cp -r public/. /output/; \
elif [ -d out ] && [ "$(ls -A out)" ]; then cp -r out/. /output/; \
else cp -r . /output/; fi
FROM nginx:alpine FROM nginx:alpine
WORKDIR /usr/share/nginx/html RUN rm -rf /usr/share/nginx/html/*
RUN rm -rf ./* COPY --from=builder /output /usr/share/nginx/html
COPY --from=builder /app/dist ./ 2>/dev/null || true
COPY --from=builder /app/build ./ 2>/dev/null || true
COPY --from=builder /app/public ./ 2>/dev/null || true
COPY --from=builder /app/out ./ 2>/dev/null || true
COPY --from=builder /app ./ 2>/dev/null || true
EXPOSE 80 EXPOSE 80
` `
} else { } else {