From bc879183d246746294dc9ed5f45f75cf8b5b6ddb Mon Sep 17 00:00:00 2001 From: Mika Hietanen Date: Wed, 27 Nov 2024 08:34:58 +0200 Subject: [PATCH 1/2] Update to support Sentry v.8 --- package-lock.json | 6 +++--- server/server.js | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f4643926..49a9bd448 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16437,9 +16437,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "funding": [ { "type": "github", diff --git a/server/server.js b/server/server.js index b0ee473be..0864a8bce 100644 --- a/server/server.js +++ b/server/server.js @@ -52,7 +52,7 @@ const setupTests = () => { setupTests(); // Handle sitemap creation - if (sitemapActive()) { +if (sitemapActive()) { // Generate sitemap on start generateSitemap(); // Update sitemap every monday @@ -70,10 +70,6 @@ const supportedLanguages = config.supportedLanguages; // This is required for proxy setups to work in production app.set('trust proxy', true); -// The request handler must be the first middleware on the app -if (Sentry) { - app.use(Sentry.Handlers.requestHandler()); -} // Add static folder app.use(express.static(path.resolve(__dirname, 'src'))); @@ -151,9 +147,9 @@ app.get('/*', (req, res, next) => { res.end(htmlTemplate(req, reactDom, preloadedState, css, cssString, emotionCss, locale, helmet, customValues)); }); -// The error handler must be before any other error middleware +// Setup Sentry error handler if (Sentry) { - app.use(Sentry.Handlers.errorHandler()); + Sentry.setupExpressErrorHandler(app); } console.log('Application version tag:', GIT_TAG, 'commit:', GIT_COMMIT); console.log(`Starting server on port ${process.env.PORT || 2048}`); From e4dc4caf889afbd13a6c9b75a7a2c15d99d8c65b Mon Sep 17 00:00:00 2001 From: Mika Hietanen Date: Wed, 27 Nov 2024 08:47:57 +0200 Subject: [PATCH 2/2] Update Docker Compose configuration Also update README --- .dockerignore | 1 - README.md | 13 +++++++++++-- docker-compose.yml | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index cfdff5982..a2047d9fd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,6 @@ node_modules/ dist/ build/ -.env .env.example .travis.yml .docker-compose.yml diff --git a/README.md b/README.md index da240c428..db9d8d7fb 100755 --- a/README.md +++ b/README.md @@ -38,19 +38,28 @@ Launches Jest test runner.
Launches TestCafe test runner and performs browser tests on headless chrome.
### `npm run browserTestCLI` -Launches the application using `node dist` command and then launches TestCafe test runner in headless mode. Mainly used by Travis CI. +Launches the application using `node dist` command and then launches TestCafe test runner in headless mode. Mainly used in GitHub Actions. ## How to use For development: - Make sure npm packages are installed by running `npm install --legacy-peer-deps`in project root. - Make sure you have environment variables set. `.env.example` should have all required values so you can copy it to `.env`. - Then you can start development server using `npm run dev`. Which watches files and updates on code changes. +- Open the application by loading `localhost:2048` in the browser To run in production mode: - Make sure npm packages are installed by running `npm install --legacy-peer-deps`in project root. - Make sure you have environment variables set. `.env.example` should have all required values so you can copy it to `.env`. - Build files by running `npm run build` -- Then you can just run the app with `npm start` +- Then you can run the app with `npm start` +- Open the application by loading `localhost:2048` in the browser + +To run with docker compose: +- Install Docker if not installed, check that port `2048` is free, not occupied by running server. +- Make sure you have environment variables set. `.env.example` should have all required values so you can copy it to `.env`. +- Run `docker compose up` +- Open the application by loading `localhost:2048` in the browser + ## Environment variables This is a documentation (some day hopefully exhaustive) of environment variables and how to use them. diff --git a/docker-compose.yml b/docker-compose.yml index 11aa61080..6e75a31eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,5 @@ -version: "3.8" services: - web: + app: build: . ports: - "2048:2048"