|
1 | | -FROM registry.access.redhat.com/ubi9/nodejs-22:9.5 |
| 1 | +# ============================================================ |
| 2 | +# STAGE 1: Install dependencies |
| 3 | +# ============================================================ |
| 4 | +FROM helsinki.azurecr.io/ubi9/nodejs-22-pnpm-builder-base AS appbase |
2 | 5 |
|
3 | | -# Create app directory |
4 | 6 | WORKDIR /servicemap-ui |
5 | 7 |
|
6 | | -USER root |
| 8 | +COPY --chown=default:root package.json pnpm-lock.yaml pnpm-workspace.yaml index.html vite.config.js .eslintrc.json ./ |
| 9 | +COPY --chown=default:root ./scripts ./scripts |
| 10 | +COPY --chown=default:root ./client ./client |
| 11 | +COPY --chown=default:root ./config ./config |
| 12 | +COPY --chown=default:root ./server ./server |
| 13 | +COPY --chown=default:root ./src ./src |
7 | 14 |
|
8 | | -RUN curl --fail --silent --proto '=https' --tlsv1.2 https://dl.yarnpkg.com/rpm/yarn.repo \ |
9 | | - --output /etc/yum.repos.d/yarn.repo |
10 | | -RUN yum -y install yarn |
| 15 | +# corepack in the base image will automatically use the version of pnpm |
| 16 | +# defined in your package.json 'packageManager' field if present. |
| 17 | +RUN pnpm install --frozen-lockfile --ignore-scripts && pnpm store prune |
11 | 18 |
|
12 | | -RUN chown -R default:root /servicemap-ui |
13 | | - |
14 | | -# Install app dependencies |
15 | | -COPY --chown=default:root --chmod=444 package.json yarn.lock /servicemap-ui/ |
16 | | - |
17 | | -# Install dependencies |
18 | | -RUN yarn install --frozen-lockfile --ignore-scripts && yarn cache clean --force |
19 | | - |
20 | | -COPY --chown=default:root . /servicemap-ui/ |
21 | | - |
22 | | -USER default |
| 19 | +# ============================================================ |
| 20 | +# STAGE 2: Build |
| 21 | +# ============================================================ |
| 22 | +FROM appbase AS builder |
23 | 23 |
|
| 24 | +#ARG REACT_APP_SENTRY_RELEASE |
24 | 25 | ARG NODE_OPTIONS=--max-old-space-size=4096 |
25 | 26 | ENV NODE_OPTIONS=$NODE_OPTIONS |
26 | 27 |
|
27 | | -RUN yarn build |
| 28 | +RUN pnpm build |
28 | 29 |
|
29 | | -USER root |
| 30 | +# ============================================================ |
| 31 | +# STAGE 3: Production Runtime |
| 32 | +# ============================================================ |
| 33 | +# This app is SSR (Express + React server-side rendering) — it requires a |
| 34 | +# Node runtime, not a static file server like nginx. |
| 35 | +FROM registry.access.redhat.com/ubi9/nodejs-22-minimal AS production |
30 | 36 |
|
31 | | -RUN chown root:root -R /servicemap-ui && chmod -R 755 /servicemap-ui |
| 37 | +WORKDIR /servicemap-ui |
| 38 | + |
| 39 | +# Copy built server bundle and client assets |
| 40 | +COPY --from=builder --chown=1001:root /servicemap-ui/dist ./dist |
32 | 41 |
|
33 | | -USER default |
| 42 | +# Copy node_modules for externalized runtime dependencies (react, react-dom, etc.) |
| 43 | +COPY --from=appbase --chown=1001:root /servicemap-ui/node_modules ./node_modules |
34 | 44 |
|
35 | | -# If you are building your code for production |
36 | | -# RUN npm ci --only=production |
| 45 | +#ARG REACT_APP_SENTRY_RELEASE |
| 46 | +ENV NODE_ENV=production |
| 47 | + |
| 48 | +USER 1001 |
37 | 49 |
|
38 | | -# Bundle app source |
39 | 50 | EXPOSE 2048 |
40 | | -CMD [ "node", "dist/index.js" ] |
| 51 | + |
| 52 | +CMD ["node", "dist"] |
0 commit comments