Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Use the latest LTS version of Node.js
# https://hub.docker.com/_/node
FROM node:22@sha256:37ff334612f77d8f999c10af8797727b731629c26f2e83caa6af390998bdc49c AS build-stage
# BUILD STAGE
FROM node:24-slim@sha256:36ae19f59c91f3303c7a648f07493fe14c4bd91320ac8d898416327bacf1bbfa AS build-stage
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
Expand All @@ -14,11 +13,21 @@ ENV NODE_ENV=production
COPY . .
RUN npm run build

# The same image but now only install the production dependencies as the frontend is already built using vite in the build-stage
FROM gcr.io/distroless/nodejs22-debian12@sha256:b765815eafacee5222bfa50179028f41dd8c642b68ad68ec4e6922d3b1ff2710 AS production
# Remove dev dependencies so the node_modules directory that we COPY into the distroless image contains only runtime dependencies
RUN npm prune --omit=dev


# PRODUCTION STAGE
FROM gcr.io/distroless/nodejs24-debian12@sha256:20a51c926c0bb68a9b1f7059c81516da002655f8a896a2cb7bc56b56974782b3 AS production
WORKDIR /usr/src/app

COPY --from=build-stage /usr/src/app /usr/src/app
# Copy built files
COPY --from=build-stage /usr/src/app/dist/client /usr/src/app/dist/client
COPY --from=build-stage /usr/src/app/dist/vite.config.json /usr/src/app/dist/vite.config.json
COPY --from=build-stage /usr/src/app/dist/server /usr/src/app/server
COPY --from=build-stage /usr/src/app/dist/server.js /usr/src/app/server.js
COPY --from=build-stage /usr/src/app/public /usr/src/app/public
COPY --from=build-stage /usr/src/app/node_modules /usr/src/app/node_modules

# Run
CMD ["server.js"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ The UI will be served on http://localhost:5173.
To enable local development with Safari, follow these steps on your local machine:

1. **Update Cookie Settings:**
In [`server/encrypted-session.js`](server/encrypted-session.js), set the `secure` property to `false` in both occurrences.
In [`server/encrypted-session.js`](server/encrypted-session.ts), set the `secure` property to `false` in both occurrences.

2. **Disable Helmet Registration:**
In [`server.js`](server.js), comment out or remove the registration of `helmet`.
In [`server.js`](server.ts), comment out or remove the registration of `helmet`.


### Build & Production
Expand Down
181 changes: 180 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"version": "0.0.0",
"type": "module",
"engines": {
"node": "^22.0.0",
"node": "^24.0.0",
"npm": "^11.0.0"
},
"scripts": {
"dev": "node server.js --local-dev",
"start": "node server.js",
"build": "tsc && vite build",
"dev": "node --loader ts-node/esm ./server.ts --local-dev",
"start": "node dist/server/server.js",
"build": "tsc && npm run build:server && vite build",
"build:server": "tsc -p tsconfig.server.json",
"lint": "eslint ./src --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"test:vi": "vitest",
Expand Down Expand Up @@ -81,8 +82,10 @@
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.2.0",
"fastify-tsconfig": "^3.0.0",
"globals": "^16.0.0",
"prettier": "^3.5.3",
"ts-node": "^10.9.2",
"typescript": "^5.7.3",
"typescript-eslint": "^8.26.1",
"vite": "^6.3.4",
Expand Down
6 changes: 6 additions & 0 deletions server.js → server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if (!process.env.BFF_SENTRY_DSN || process.env.BFF_SENTRY_DSN.trim() === '') {
beforeSend(event) {
if (event.request && event.request.cookies) {
event.request.cookies = Object.keys(event.request.cookies).reduce((acc, key) => {
// @ts-ignore
acc[key] = '';
return acc;
}, {});
Expand Down Expand Up @@ -49,8 +50,10 @@ Sentry.setupFastifyErrorHandler(fastify);
await fastify.register(envPlugin);

let sentryHost = '';
// @ts-ignore
if (fastify.config.VITE_SENTRY_DSN && fastify.config.VITE_SENTRY_DSN.length > 0) {
try {
// @ts-ignore
sentryHost = new URL(fastify.config.VITE_SENTRY_DSN).hostname;
} catch {
console.log('VITE_SENTRY_DSN is not a valid URL');
Expand All @@ -63,6 +66,7 @@ fastify.register(helmet, {
directives: {
'connect-src': ["'self'", 'sdk.openui5.org', sentryHost],
'script-src': isLocalDev ? ["'self'", "'unsafe-inline'"] : ["'self'"],
// @ts-ignore
'frame-ancestors': [fastify.config.FRAME_ANCESTORS],
},
},
Expand All @@ -78,6 +82,7 @@ await fastify.register(FastifyVite, {
spa: true,
});

// @ts-ignore
fastify.get('/', function (req, reply) {
return reply.html();
});
Expand All @@ -88,6 +93,7 @@ fastify.listen(
port: 5173,
host: '0.0.0.0',
},
// @ts-ignore
function (err, address) {
if (err) {
fastify.log.error(err);
Expand Down
Loading
Loading