Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
11081b1
feat: vite ssr, material-ui Refs: PL-292
mikkojamG May 20, 2026
af17546
feat: vite ssr, entry points Refs: PL-292
mikkojamG May 20, 2026
2a77040
feat: vite ssr, unified server Refs: PL-292
mikkojamG May 20, 2026
db4073d
feat: vite ssr, vite config & build scripts Refs: PL-292
mikkojamG May 20, 2026
cae08ea
feat: vite ssr, Dockerfile changes Refs: PL-292
mikkojamG May 20, 2026
0059166
feat: vite ssr, cleanup Refs: PL-292
mikkojamG May 20, 2026
1dcc0fa
chore: migration fixes Refs: PL-292
mikkojamG May 20, 2026
df32c22
fix: server rate-limit, template cache Refs: PL-292
mikkojamG Jun 9, 2026
150228f
fix: server.mjs unsafe redirect Refs: PL-292
mikkojamG Jun 9, 2026
f2b7456
ci: eslint import rules Refs: PL-292
mikkojamG Jun 9, 2026
a049400
ci: dockerfile copy new server Refs: PL-292
mikkojamG Jun 9, 2026
b43cb85
fix: vite SSR bug fixes Refs: PL-292
mikkojamG Jun 9, 2026
70d0cbb
ci: lint:fix script Refs: PL-292
mikkojamG Jun 9, 2026
f3a516c
ci: fix failing e2e tests Refs: PL-292
mikkojamG Jun 10, 2026
6819e9f
ci: sonar fixes Refs: PL-292
mikkojamG Jun 10, 2026
6a4cffc
ci: temporary pipeline Refs: PL-292
mikkojamG Jun 10, 2026
4b9469b
ci: server-entry fix Refs: PL-292
mikkojamG Jun 10, 2026
efc61a7
fix: merge conflicts, hds cookie shim Refs: PL-292
mikkojamG Jun 12, 2026
d7e13e4
fix: dev HMR working Refs: PL-292
mikkojamG Jun 12, 2026
0d22e39
fix: lint fix Refs: PL-292
mikkojamG Jun 12, 2026
0fdba2c
ci: set NODE_ENV Refs: PL-292
mikkojamG Jun 12, 2026
4100b59
ci: run in prod mode Refs: PL-292
mikkojamG Jun 12, 2026
d35d531
chore: fixing NODE_ENV build conflicts Refs: PL-292
mikkojamG Jul 2, 2026
e4fd410
chore: server express rate limit keyGenerator Refs: PL-292
mikkojamG Jul 2, 2026
f553349
chore: drop migration plan Refs: PL-292
mikkojamG Jul 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .babelrc

This file was deleted.

3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"import/order": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/named": "off"
"import/named": "off",
"import/no-unresolved": ["error", { "ignore": ["^\\./dist/"] }]
}
}
36 changes: 27 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,55 @@ FROM helsinki.azurecr.io/ubi9/nodejs-24-pnpm-builder-base AS appbase

COPY --chown=default:root package.json pnpm-lock.yaml pnpm-workspace.yaml index.html vite.config.js .eslintrc.json .env ./
COPY --chown=default:root ./scripts ./scripts
COPY --chown=default:root ./client ./client
COPY --chown=default:root ./config ./config
COPY --chown=default:root ./server ./server
COPY --chown=default:root server.mjs ./
COPY --chown=default:root ./public ./public
COPY --chown=default:root ./src ./src
Comment thread
mikkojamG marked this conversation as resolved.

# 2. Run install
# corepack in the base image will automatically use the version of pnpm
# defined in your package.json 'packageManager' field if present.
RUN pnpm install --frozen-lockfile --ignore-scripts && pnpm store prune

COPY --chown=default:root ./.git ./.git
# ============================================================
# STAGE 2: Build
# STAGE 2: Development
# ============================================================
FROM appbase AS builder
FROM appbase AS development

# Set NODE_ENV to development in the development container
ARG NODE_ENV=development
ENV NODE_ENV $NODE_ENV

CMD ["pnpm", "dev"]

# ============================================================
# STAGE 3: Build
# ============================================================
FROM appbase AS staticbuilder

ARG NODE_OPTIONS=--max-old-space-size=4096
ENV NODE_OPTIONS=$NODE_OPTIONS
ENV NODE_ENV=production

RUN pnpm build

# ============================================================
# STAGE 3: Production Runtime
# STAGE 4: Production Runtime
# ============================================================
# This app is SSR (Express + React server-side rendering) — it requires a
# Node runtime, not a static file server like nginx.
FROM registry.access.redhat.com/ubi9/nodejs-24-minimal AS production

WORKDIR /servicemap-ui

# Copy built server bundle and client assets
COPY --from=builder --chown=1001:root /app/dist ./dist
# Copy built assets and the unified server entry point
COPY --from=staticbuilder --chown=1001:root /app/dist ./dist
COPY --from=staticbuilder --chown=1001:root /app/server.mjs ./server.mjs
COPY --from=staticbuilder --chown=1001:root /app/server ./server
COPY --from=staticbuilder --chown=1001:root /app/config ./config
COPY --from=staticbuilder --chown=1001:root /app/package.json ./package.json

# Copy .env so update-runtime-env.js can use it as a fallback at container startup
# for any variable not present in the Azure ConfigMap. process.env (ConfigMap) wins.
Expand All @@ -45,8 +62,9 @@ COPY --from=appbase --chown=1001:root /app/.env ./.env
# Copy scripts needed at container startup (update-runtime-env.js)
COPY --from=appbase --chown=1001:root /app/scripts ./scripts

# Copy node_modules for externalized runtime dependencies (react, react-dom, etc.)
COPY --from=appbase --chown=1001:root /app/node_modules ./node_modules
# Copy node_modules from staticbuilder so the hds-core cookie-consent shim
# (applied during pnpm build via fix-hds-shim) is present at runtime.
COPY --from=staticbuilder --chown=1001:root /app/node_modules ./node_modules

# OpenShift runs containers with a random UID in group 0 (root group).
# Make dist/ group-writable so update-runtime-env.js can overwrite env-config.js
Expand All @@ -63,4 +81,4 @@ EXPOSE 8080
# baked-in build-time defaults in dist/env-config.js before the server starts.
# The existing dist/env-config.js serves as the fallback for any variable that
# is not present in the runtime environment.
CMD ["sh", "-c", "node scripts/update-runtime-env.js && exec node dist"]
CMD ["sh", "-c", "node scripts/update-runtime-env.js && exec node server.mjs"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ Launches Vitest test runner.<br>
### `pnpm test:e2e`
Launches [Playwright](playwright.config.js) test runner and performs browser tests.

### `pnpm fix-hds-shim`

Workaround for a packaging issue in `hds-core@6.x`: generates a missing `cookieConsent.js` file that `hds-react` expects but the package does not ship.
This is run automatically by `pnpm dev` and `pnpm build`. Run it manually if you encounter a `MODULE_NOT_FOUND` error for `hds-core/lib/components/cookie-consent/cookieConsent` after installing dependencies.
Can be removed once HDS publishes a fixed release.

## How to use
For development:
- Make sure packages are installed by running `pnpm install` in project root.
Expand Down
1 change: 0 additions & 1 deletion __mocks__/withStyles.js

This file was deleted.

133 changes: 0 additions & 133 deletions client/client.js

This file was deleted.

7 changes: 6 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ services:
platform: linux/amd64
ports:
- "3000:8080"
build: .
build:
context: .
target: ${DOCKER_TARGET:-development}
environment:
- PORT=8080
env_file:
- .env
- .env.local
volumes:
- ".:/app"
- "/app/node_modules"
container_name: servicemap-ui
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import config from './default';
import config from './default.js';

export default config;
1 change: 1 addition & 0 deletions config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "type": "module" }
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!doctype html>
<html lang="en">
<html lang="fi">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="/src/assets/icons/favicon.ico" />
<script type="module" src="/env-config.js"></script>
<title>Palvelukartta</title>
<!--app-head-->
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="app"></div>
<script type="module" src="/client/client.js"></script>
<div id="app"><!--app-html--></div>
<script type="module" src="/src/entry-client.jsx"></script>
</body>
</html>
40 changes: 14 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@formatjs/intl-relativetimeformat": "^4.5.16",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@mui/styles": "^6.1.4",
"@mui/utils": "^6.1.4",
"@sentry/node": "^10.27.0",
"@sentry/react": "^10.20.0",
Expand All @@ -30,21 +29,18 @@
"@vitejs/plugin-react": "^5.0.3",
"@vitest/coverage-istanbul": "^4.1.0",
"compression": "^1.8.1",
"core-js": "^3.25.1",
"d3": "^7.9.0",
"dotenv": "^16.6.1",
"esrun": "^3.2.30",
"express": "^4.21.2",
"express-rate-limit": "^8.5.2",
"express-sitemap": "^1.8.0",
"hds-design-tokens": "6.0.2",
"hds-react": "6.0.2",
"http-status-typed": "^2.0.1",
"intl": "^1.2.5",
"isomorphic-style-loader": "^5.4.0",
"leaflet": "1.9.4",
"leaflet.heightgraph": "^1.4.0",
"leaflet.markercluster": "^1.5.3",
"node-fetch": "^2.6.7",
"node-schedule": "^2.0.0",
"proj4leaflet": "^1.0.2",
"prop-types": "^15.7.2",
Expand All @@ -59,34 +55,29 @@
"react-router-dom": "^6.30.3",
"redux": "^5.0.1",
"redux-thunk": "^3.1.0",
"regenerator-runtime": "^0.13.7",
"remark-gfm": "^4.0.1",
"reselect": "^4.1.6",
"sitemap": "^6.4.0",
"urijs": "^1.19.11",
"vite": "^7.3.2",
"vitest": "^4.1.0",
"whatwg-fetch": "^3.5.0"
"vite-plugin-cjs-interop": "^3.3.0",
"vitest": "^4.1.0"
},
"scripts": {
"build": "rm -rf dist && pnpm build:client && pnpm build:server && pnpm update-runtime-env",
"build:test": "rm -rf dist && pnpm build:client --mode development && pnpm build:server --mode development",
"build:client": "vite build",
"build:server": "BUILD_TARGET=server vite build --ssr",
"build:client:clean": "rm -rf dist/src && pnpm build:client",
"build:server:clean": "rm -f dist/server.js dist/server.js.map && pnpm build:server",
"dev": "pnpm update-runtime-env && pnpm dev:client:watch & pnpm dev:server:watch & sleep 5 && nodemon dist --watch dist",
"dev:client:watch": "vite build --watch",
"dev:server:watch": "BUILD_TARGET=server vite build --ssr --watch",
"lint": "eslint src/ server/ --ext .js,.jsx && prettier src/ server/ --check",
"lint:fix": "eslint src/ server/ --ext .js,.jsx --fix && prettier src/ server/ --write",
"preview": "vite preview",
"start": "node dist",
"build": "rm -rf dist && pnpm fix-hds-shim && pnpm update-runtime-env && pnpm build:client && pnpm build:server",
"build:client": "vite build --outDir dist/client --ssrManifest",
"build:server": "vite build --ssr server/server-entry.js --outDir dist/server",
"dev": "pnpm fix-hds-shim && pnpm update-runtime-env && VITE_DEV=true node server.mjs",
"lint": "eslint src/ server/ server.mjs --ext .js,.jsx,.mjs && prettier src/ server/ server.mjs --check",
"lint:fix": "eslint src/ server/ server.mjs --ext .js,.jsx,.mjs --fix && prettier src/ server/ server.mjs --write",
"preview": "NODE_ENV=production node server.mjs",
"start": "NODE_ENV=production node server.mjs",
"test": "NODE_ENV=test pnpm update-runtime-env && vitest --config vitest.config.js",
"test:coverage": "pnpm test --coverage",
"test:e2e:install": "playwright install",
"test:e2e": "playwright test",
"update-runtime-env": "esrun scripts/update-runtime-env.js"
"update-runtime-env": "esrun scripts/update-runtime-env.js",
"fix-hds-shim": "node scripts/fix-hds-core-cookie-consent.js"
},
"browserslist": [
">0.2%",
Expand Down Expand Up @@ -119,11 +110,8 @@
"eslint-plugin-vitest-globals": "^1.6.1",
"identity-obj-proxy": "^3.0.0",
"jsdom": "^27.0.0",
"nodemon": "^2.0.20",
"prettier": "^3.6.2",
"redux-mock-store": "^1.5.4",
"typescript": "^5.9.3",
"vite-plugin-commonjs": "^0.10.4",
"vite-plugin-node-polyfills": "^0.24.0"
"typescript": "^5.9.3"
}
}
Loading
Loading