Skip to content

Commit 45411fb

Browse files
committed
feat: replace yarn with pnpm
Refs: PT-2045
1 parent 2a521bd commit 45411fb

38 files changed

Lines changed: 12279 additions & 9757 deletions

.dockerignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@
44
!.prettierrc.json
55
!.prod
66
!.release-please-manifest.json
7+
!.env.example
8+
!.env.runtime.template
9+
!.env.playwright.local.example
10+
!.env.development.local.example
711
!codegen.yml
812
!commitlint.config.js
913
!eslint.config.mjs
1014
!index.html
1115
!package.json
16+
!pnpm-lock.yaml
17+
!pnpm-workspace.yaml
1218
!printVersion.js
1319
!public
1420
!release-please-config.json
21+
!scripts
22+
!scripts/**
1523
!src
1624
!tsconfig.json
1725
!tsconfig.node.json
1826
!vite.config.ts
1927
!vitest.config.ts
20-
!yarn.lock

.env.development.local.example

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# Local environment variable overrides:
2-
# See https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
1+
# Local overrides for Vite development mode.
32
#
4-
# Files on the left have more priority than files on the right:
5-
# - npm start: .env.development.local, .env.local, .env.development, .env
6-
# - npm run build: .env.production.local, .env.local, .env.production, .env
7-
# - npm test: .env.test.local, .env.test, .env (note .env.local is missing)
3+
# File naming follows Vite conventions. This file is intended for local-only
4+
# development overrides and should not be committed.
85

96
# Endpoint URI overrides for the fully local development environment..
107
# When running a local API, then also the LinkedEvents needs to be local.

.env.example

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
# Default environment variables
2-
# See https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
1+
# Default environment variables for Vite-based tooling.
32
#
4-
# Files on the left have more priority than files on the right:
5-
# - npm start: .env.development.local, .env.local, .env.development, .env
6-
# - npm run build: .env.production.local, .env.local, .env.production, .env
7-
# - npm test: .env.test.local, .env.test, .env (note .env.local is missing)
3+
# Vite file priority (highest to lowest):
4+
# 1) Existing process env
5+
# 2) .env.[mode].local
6+
# 3) .env.[mode]
7+
# 4) .env.local
8+
# 5) .env
9+
#
10+
# In this project:
11+
# - pnpm dev uses mode "development"
12+
# - pnpm build uses mode "production"
13+
# - pnpm test:coverage loads .env and .env.test in src/test/vitest-setup.ts
814
VITE_APP_ORIGIN=http://localhost:3000
915
# Staging CMS URI:
1016
VITE_APP_CMS_URI=https://kultus.app-staging.hkih.hion.dev/graphql
1117
# Production CMS URI:
1218
# VITE_APP_CMS_URI=https://kultus.content.api.hel.fi/graphql
13-
VITE_APP_APPLICATION_NAME=$npm_package_name
14-
VITE_APP_VERSION=$npm_package_version
1519

1620
# Sentry
1721
VITE_APP_SENTRY_ENVIRONMENT=local

.env.runtime.template

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
VITE_APP_ORIGIN=
2+
VITE_APP_CMS_URI=
3+
VITE_APP_SENTRY_ENVIRONMENT=
4+
VITE_APP_SENTRY_DSN=
5+
VITE_APP_SENTRY_TRACES_SAMPLE_RATE=
6+
VITE_APP_SENTRY_TRACE_PROPAGATION_TARGETS=
7+
VITE_APP_SENTRY_REPLAYS_SESSION_SAMPLE_RATE=
8+
VITE_APP_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=
9+
VITE_APP_CSP_REPORT_URI=
10+
VITE_APP_API_URI=
11+
VITE_APP_API_REPORT_URI=
12+
VITE_APP_LINKEDEVENTS_API_URI=
13+
VITE_APP_OIDC_AUDIENCES=
14+
VITE_APP_OIDC_RETURN_TYPE=
15+
VITE_APP_OIDC_SERVER_TYPE=
16+
VITE_APP_OIDC_API_CLIENT_ID=
17+
VITE_APP_OIDC_AUTHORITY=
18+
VITE_APP_OIDC_CLIENT_ID=
19+
VITE_APP_OIDC_SCOPE=
20+
VITE_APP_OIDC_AUTOMATIC_SILENT_RENEW_ENABLED=
21+
VITE_APP_HELSINKI_PROFILE_URL=
22+
VITE_APP_IDLE_TIMEOUT_IN_MS=
23+
VITE_APP_APPLICATION_NAME=
24+
VITE_APP_VERSION=
25+
VITE_APP_COMMITHASH=
26+
VITE_APP_BUILDTIME=
27+
VITE_APP_SENTRY_RELEASE=

.env.test

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Test environment variables (used by Vitest + update-runtime-env in test mode)
2+
3+
VITE_APP_ORIGIN=http://localhost:3000
4+
VITE_APP_CMS_URI=https://kultus.app-staging.hkih.hion.dev/graphql
5+
VITE_APP_APPLICATION_NAME=$npm_package_name
6+
VITE_APP_VERSION=$npm_package_version
7+
8+
# Sentry
9+
VITE_APP_SENTRY_ENVIRONMENT=test
10+
VITE_APP_SENTRY_DSN=
11+
VITE_APP_SENTRY_TRACES_SAMPLE_RATE=1.0
12+
VITE_APP_SENTRY_TRACE_PROPAGATION_TARGETS=http://localhost:8081/graphql
13+
VITE_APP_SENTRY_REPLAYS_SESSION_SAMPLE_RATE=0
14+
VITE_APP_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=0
15+
VITE_APP_CSP_REPORT_URI=
16+
17+
# API / backend services
18+
VITE_APP_API_URI=https://kultus.api.test.hel.ninja/graphql
19+
VITE_APP_API_REPORT_URI=https://kultus.api.test.hel.ninja/reports
20+
VITE_APP_LINKEDEVENTS_API_URI=https://linkedevents.api.test.hel.ninja/v1
21+
22+
# OIDC client configuration
23+
VITE_APP_OIDC_AUDIENCES=kultus-api-test,profile-api-test
24+
VITE_APP_OIDC_RETURN_TYPE=code
25+
VITE_APP_OIDC_SERVER_TYPE=KEYCLOAK
26+
VITE_APP_OIDC_API_CLIENT_ID=kultus-api-test
27+
VITE_APP_OIDC_AUTHORITY=https://tunnistus.test.hel.ninja/auth/realms/helsinki-tunnistus
28+
VITE_APP_OIDC_CLIENT_ID=kultus-admin-ui-test
29+
VITE_APP_OIDC_SCOPE="openid profile email"
30+
VITE_APP_OIDC_AUTOMATIC_SILENT_RENEW_ENABLED=1
31+
32+
# Helsinki profile UI URI (for link)
33+
VITE_APP_HELSINKI_PROFILE_URL=https://profiili.test.hel.ninja/loginsso
34+
35+
# Client session timeout in ms
36+
VITE_APP_IDLE_TIMEOUT_IN_MS=3600000

.github/workflows/ci.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main, master ]
5+
branches: [main, master]
66
pull_request:
7-
branches: [ main, master ]
7+
branches: [main, master]
88
workflow_dispatch:
99

1010
jobs:
1111
common:
12-
uses: City-of-Helsinki/.github/.github/workflows/ci-node.yml@main
13-
secrets: inherit
12+
uses: City-of-Helsinki/.github/.github/workflows/ci-pnpm-node.yml@main
13+
secrets:
14+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1415
with:
15-
node-version: 22
16-
extra-commands: |
17-
cp .env.example .env
16+
node-version: 24.x

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ sonar-report.*
1111

1212
# production
1313
/build
14+
/public/env-config.js
15+
/public/test-env-config.js
1416

1517
# misc
1618
.DS_Store
@@ -24,7 +26,6 @@ sonar-report.*
2426
.env.playwright.local
2527
.env.production
2628
.env.production.local
27-
.env.test
2829
.env.test.local
2930

3031
npm-debug.log*

.husky/pre-commit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
yarn doctoc . -u
2-
yarn lint-staged --relative
1+
pnpm doctoc . -u
2+
pnpm lint-staged --relative

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.13.1
1+
v24.15.0

Dockerfile

Lines changed: 51 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
1-
# ===============================================
2-
FROM registry.access.redhat.com/ubi9/nodejs-22 AS appbase
3-
# ===============================================
4-
5-
# install yarn
6-
USER root
7-
RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
8-
RUN yum -y install yarn
9-
1+
# ============================================================
2+
# STAGE 1: Build the Static Assets
3+
# ============================================================
4+
FROM helsinki.azurecr.io/ubi9/nodejs-24-pnpm-builder-base AS appbase
105
WORKDIR /app
116

12-
# Offical image has npm log verbosity as info. More info - https://github.com/nodejs/docker-node#verbosity
13-
ENV NPM_CONFIG_LOGLEVEL warn
14-
15-
# set our node environment, either development or production
16-
# defaults to production, compose overrides this to development on build and run
17-
ARG NODE_ENV=${NODE_ENV:-"production"}
18-
ENV NODE_ENV $NODE_ENV
19-
20-
# Global npm deps in a non-root user directory
21-
ENV NPM_CONFIG_PREFIX=/app/.npm-global
22-
ENV PATH=$PATH:/app/.npm-global/bin
23-
24-
# Yarn
25-
ENV YARN_VERSION 1.22.22
26-
RUN yarn policies set-version ${YARN_VERSION}
7+
# 1. Copy needed files for build
8+
COPY --chown=default:root package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json tsconfig.node.json ./
9+
COPY --chown=default:root ./public ./public
10+
COPY --chown=default:root ./scripts ./scripts
11+
COPY --chown=default:root .env.runtime.template ./
2712

28-
# Copy package.json and package-lock.json/yarn.lock files
29-
COPY --chown=default:root package*.json *yarn* ./
13+
# 2. Run the install
14+
# corepack in the base image will automatically use the version of pnpm
15+
# defined in your package.json 'packageManager' field if present.
16+
RUN pnpm install --frozen-lockfile --ignore-scripts && pnpm store prune
17+
RUN pnpm update-runtime-env
3018

31-
# Install npm dependencies
32-
ENV PATH /app/node_modules/.bin:$PATH
19+
# 3. Copy remaining source files
20+
COPY --chown=default:root index.html vite.config.ts eslint.config.mjs .prettierrc.json .env* ./
21+
COPY --chown=default:root ./src ./src
3322

34-
RUN yarn install --frozen-lockfile --ignore-scripts && yarn cache clean --force
3523

36-
# =============================
24+
# ============================================================
25+
# STAGE 2: Development
26+
# ============================================================
3727
FROM appbase AS development
38-
# =============================
28+
WORKDIR /app
3929

4030
# Set NODE_ENV to development in the development container
4131
ARG NODE_ENV=development
@@ -48,99 +38,40 @@ ENV NODE_ENV $NODE_ENV
4838
ARG CHOKIDAR_USEPOLLING=true
4939
ENV CHOKIDAR_USEPOLLING=${CHOKIDAR_USEPOLLING}
5040

51-
# copy in our source code last, as it changes the most
52-
COPY --chown=default:root . .
41+
# Expose port and start development server
42+
EXPOSE 8080
43+
CMD pnpm exec vite --port 8080 --no-open --host
5344

54-
# Bake package.json start command into the image
55-
CMD ["yarn", "dev", "--no-open", "--host"]
5645

57-
# ===================================
46+
# ============================================================
47+
# STAGE 3: Static builder for production
48+
# ============================================================
5849
FROM appbase AS staticbuilder
59-
# ===================================
60-
61-
# Oidc authority
62-
ARG VITE_APP_OIDC_AUDIENCES
63-
ARG VITE_APP_OIDC_RETURN_TYPE
64-
ARG VITE_APP_OIDC_SERVER_TYPE
65-
ARG VITE_APP_OIDC_API_CLIENT_ID
66-
ARG VITE_APP_OIDC_AUTHORITY
67-
ARG VITE_APP_OIDC_CLIENT_ID
68-
ARG VITE_APP_OIDC_SCOPE
69-
ARG VITE_APP_OIDC_AUTOMATIC_SILENT_RENEW_ENABLED
70-
71-
# Sentry variables
72-
ARG VITE_APP_SENTRY_ENVIRONMENT
73-
ARG VITE_APP_SENTRY_DSN
74-
ARG VITE_APP_SENTRY_TRACES_SAMPLE_RATE
75-
ARG VITE_APP_SENTRY_TRACE_PROPAGATION_TARGETS
76-
ARG VITE_APP_SENTRY_REPLAYS_SESSION_SAMPLE_RATE
77-
ARG VITE_APP_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE
78-
ARG VITE_APP_CSP_REPORT_URI
79-
80-
# Api url
81-
ARG VITE_APP_API_URI
82-
ARG VITE_APP_CMS_URI
83-
ARG VITE_APP_API_REPORT_URI
84-
85-
# Linkedevents api url
86-
ARG VITE_APP_LINKEDEVENTS_API_URI
87-
88-
# Application's origin (i.e. where this application is hosted)
89-
ARG VITE_APP_ORIGIN
90-
91-
# Helsinki profile URL
92-
ARG VITE_APP_HELSINKI_PROFILE_URL
93-
94-
# Time before user logout if idle
95-
ARG VITE_APP_IDLE_TIMEOUT_IN_MS
96-
97-
ARG NODE_OPTIONS
98-
99-
# Fix FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed -
100-
# JavaScript heap out of memory: https://github.com/vitejs/vite/issues/2433.
101-
ENV NODE_OPTIONS=${NODE_OPTIONS}
102-
103-
# Release information
104-
ARG VITE_APP_SENTRY_RELEASE
105-
ARG VITE_APP_COMMITHASH
106-
ARG VITE_APP_BUILDTIME
107-
108-
# Use template and inject the environment variables into .prod/nginx.conf
109-
ENV VITE_APP_BUILDTIME=${VITE_APP_BUILDTIME:-""}
110-
ENV VITE_APP_RELEASE=${VITE_APP_SENTRY_RELEASE:-""}
111-
ENV VITE_APP_COMMITHASH=${VITE_APP_COMMITHASH:-""}
112-
COPY .prod/nginx.conf.template /tmp/.prod/nginx.conf.template
113-
RUN export APP_VERSION=$(yarn --silent app:version) && \
114-
envsubst '${APP_VERSION},${VITE_APP_BUILDTIME},${VITE_APP_RELEASE},${VITE_APP_COMMITHASH}' < \
115-
"/tmp/.prod/nginx.conf.template" > \
116-
"/tmp/.prod/nginx.conf"
117-
118-
# Copy all files
119-
COPY . /app
120-
121-
# Build
122-
RUN yarn build
123-
124-
# =============================
125-
FROM registry.access.redhat.com/ubi9/nginx-122 AS production
126-
# =============================
127-
# Add application sources to a directory that the assemble script expects them
128-
# and set permissions so that the container runs without root access
129-
ARG PORT
130-
131-
USER root
132-
133-
RUN chgrp -R 0 /usr/share/nginx/html && \
134-
chmod -R g=u /usr/share/nginx/html
135-
136-
# Copy static build
50+
51+
# Perform the build
52+
ARG VITE_SENTRY_RELEASE
53+
RUN pnpm build
54+
55+
56+
# ============================================================
57+
# STAGE 4: Production Runtime
58+
# ============================================================
59+
FROM helsinki.azurecr.io/ubi10/nginx-126-spa-standard AS production
60+
61+
ARG VITE_SENTRY_RELEASE
62+
ENV APP_RELEASE=${VITE_SENTRY_RELEASE:-""}
63+
# 1. Copy the compiled assets
13764
COPY --from=staticbuilder /app/build /usr/share/nginx/html
138-
# Copy nginx config
139-
COPY --from=staticbuilder /tmp/.prod/nginx.conf /etc/nginx/nginx.conf
14065

141-
USER 1001
66+
# 2. Setup Runtime Env Injection
67+
# env.sh is provided by the base image
68+
WORKDIR /usr/share/nginx/html
69+
COPY --from=staticbuilder /app/.env.runtime.template ./.env
14270

143-
# Run script uses standard ways to run the application
144-
CMD ["/bin/bash", "-c", "nginx -g \"daemon off;\""]
71+
# 3. Inject Versioning for the /readiness endpoint from package.json using base image
72+
COPY package.json .
14573

146-
EXPOSE ${PORT:-8080}
74+
# - env.sh (Inherited from base image at /usr/share/nginx/html/env.sh)
75+
# - USER 1001 (Inherited from base image)
76+
# - EXPOSE 8080 (Inherited from base image)
77+
# - ENTRYPOINT/CMD (Inherited from base image)

0 commit comments

Comments
 (0)