Skip to content

Commit 1715c1b

Browse files
committed
feat: migrate Yarn classic to pnpm Refs: PL-240
1 parent d32d1e4 commit 1715c1b

11 files changed

Lines changed: 12823 additions & 10058 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ on:
1313

1414
jobs:
1515
common:
16-
uses: City-of-Helsinki/.github/.github/workflows/ci-node.yml@main
17-
secrets: inherit
16+
uses: City-of-Helsinki/.github/.github/workflows/ci-pnpm-node.yml@main
17+
secrets:
18+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1819
with:
1920
node-version: 22.x
2021
extra-commands: |
@@ -87,11 +88,13 @@ jobs:
8788
uses: actions/setup-node@v4
8889
with:
8990
node-version: 22.x
91+
- name: Enable pnpm
92+
run: corepack enable
9093
- name: Install dependencies
91-
run: yarn install --frozen-lockfile
94+
run: pnpm install --frozen-lockfile --ignore-scripts
9295
- name: Build application
93-
run: yarn build
96+
run: pnpm build
9497
- name: Install Playwright browsers
95-
run: yarn test:e2e:install
98+
run: pnpm test:e2e:install
9699
- name: Run E2E tests
97-
run: yarn test:e2e
100+
run: pnpm test:e2e

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,9 @@
2424
/tmp
2525

2626
npm-debug.log*
27+
# yarn – not used anymore
28+
yarn.lock
29+
.yarn/
30+
.yarnrc.yml
2731
yarn-debug.log*
2832
yarn-error.log*

Dockerfile

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
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
25

3-
# Create app directory
46
WORKDIR /servicemap-ui
57

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
714

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
1118

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
2323

24+
#ARG REACT_APP_SENTRY_RELEASE
2425
ARG NODE_OPTIONS=--max-old-space-size=4096
2526
ENV NODE_OPTIONS=$NODE_OPTIONS
2627

27-
RUN yarn build
28+
RUN pnpm build
2829

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
3036

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
3241

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
3444

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
3749

38-
# Bundle app source
3950
EXPOSE 2048
40-
CMD [ "node", "dist/index.js" ]
51+
52+
CMD ["node", "dist"]

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Requirements
44
Using following:
55
* Node LTS (v22)
6-
* yarn (v1)
6+
* pnpm (v11)
77
If you are using NVM you can also use `nvm use` to get correct version.
88

99
For development:
@@ -13,41 +13,41 @@ For development:
1313

1414
In the project directory, you can run:
1515

16-
### `yarn dev`
16+
### `pnpm dev`
1717

1818
Start dev server and runs the app in the development mode.<br>
1919

20-
### `yarn build`
20+
### `pnpm build`
2121

2222
Builds the app for production to the `dist` folder.<br>
2323

24-
### `yarn build:test`
24+
### `pnpm build:test`
2525

2626
Builds the app in development mode to the `dist` folder.<br>
2727

28-
### `yarn start`
28+
### `pnpm start`
2929

3030
Runs the app by starting node server using build files.
3131

32-
### `yarn test`
32+
### `pnpm test`
3333

3434
Launches Vitest test runner.<br>
3535

36-
### `yarn test:e2e`
36+
### `pnpm test:e2e`
3737
Launches [Playwright](playwright.config.js) test runner and performs browser tests.
3838

3939
## How to use
4040
For development:
41-
- Make sure yarn packages are installed by running `yarn install` in project root.
41+
- Make sure packages are installed by running `pnpm install` in project root.
4242
- Make sure you have environment variables set. `.env.example` should have all required values so you can copy it to `.env`.
43-
- Then you can start development server using `yarn dev`. Which watches files and updates on code changes.
43+
- Then you can start development server using `pnpm dev`. Which watches files and updates on code changes.
4444
- Open the application by loading `localhost:2048` in the browser
4545

4646
To run in production mode:
47-
- Make sure yarn packages are installed by running `yarn install` in project root.
47+
- Make sure packages are installed by running `pnpm install` in project root.
4848
- Make sure you have environment variables set. `.env.example` should have all required values so you can copy it to `.env`.
49-
- Build files by running `yarn build`
50-
- Then you can run the app with `yarn start`
49+
- Build files by running `pnpm build`
50+
- Then you can run the app with `pnpm start`
5151
- Open the application by loading `localhost:2048` in the browser
5252

5353
To run with docker compose:

compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
app:
3+
platform: linux/amd64
4+
ports:
5+
- "2048:2048"
6+
build: .
7+
env_file:
8+
- .env
9+
container_name: servicemap-ui

docker-compose.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
"name": "servicemap-ui",
33
"version": "2.14.2",
44
"private": true,
5+
"packageManager": "pnpm@11.1.3",
56
"engines": {
6-
"node": ">=22.13.1"
7+
"node": ">=22.13.1",
8+
"pnpm": ">=11.1.3"
79
},
810
"dependencies": {
911
"@emotion/css": "^11.11.2",
@@ -66,21 +68,21 @@
6668
"whatwg-fetch": "^3.5.0"
6769
},
6870
"scripts": {
69-
"build": "rm -rf dist && yarn build:client && yarn build:server",
70-
"build:test": "rm -rf dist && yarn build:client --mode development && yarn build:server --mode development",
71+
"build": "rm -rf dist && pnpm build:client && pnpm build:server",
72+
"build:test": "rm -rf dist && pnpm build:client --mode development && pnpm build:server --mode development",
7173
"build:client": "vite build",
7274
"build:server": "BUILD_TARGET=server vite build --ssr",
73-
"build:client:clean": "rm -rf dist/src && yarn build:client",
74-
"build:server:clean": "rm -f dist/server.js dist/server.js.map && yarn build:server",
75-
"dev": "yarn dev:client:watch & yarn dev:server:watch & sleep 5 && nodemon dist --watch dist",
75+
"build:client:clean": "rm -rf dist/src && pnpm build:client",
76+
"build:server:clean": "rm -f dist/server.js dist/server.js.map && pnpm build:server",
77+
"dev": "pnpm dev:client:watch & pnpm dev:server:watch & sleep 5 && nodemon dist --watch dist",
7678
"dev:client:watch": "vite build --watch",
7779
"dev:server:watch": "BUILD_TARGET=server vite build --ssr --watch",
7880
"lint": "eslint src/ server/ --ext .js,.jsx && prettier src/ server/ --check",
7981
"lint:fix": "eslint src/ server/ --ext .js,.jsx --fix && prettier src/ server/ --write",
8082
"preview": "vite preview",
8183
"start": "node dist",
8284
"test": "vitest --config vitest.config.js",
83-
"test:coverage": "yarn test --coverage",
85+
"test:coverage": "pnpm test --coverage",
8486
"test:e2e:install": "playwright install",
8587
"test:e2e": "playwright test"
8688
},
@@ -120,8 +122,5 @@
120122
"redux-mock-store": "^1.5.4",
121123
"vite-plugin-commonjs": "^0.10.4",
122124
"vite-plugin-node-polyfills": "^0.24.0"
123-
},
124-
"resolutions": {
125-
"**/@typescript-eslint/typescript-estree/minimatch": "9.0.7"
126125
}
127126
}

0 commit comments

Comments
 (0)