Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sentry 8 and Docker / Docker Compose supports #1209

Merged
merged 2 commits into from
Nov 27, 2024
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
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules/
dist/
build/
.env
.env.example
.travis.yml
.docker-compose.yml
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,28 @@ Launches Jest test runner.<br>
Launches TestCafe test runner and performs browser tests on headless chrome.<br>

### `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.
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: "3.8"
services:
web:
app:
build: .
ports:
- "2048:2048"
6 changes: 3 additions & 3 deletions package-lock.json

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

10 changes: 3 additions & 7 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const setupTests = () => {
setupTests();

// Handle sitemap creation
if (sitemapActive()) {
if (sitemapActive()) {
// Generate sitemap on start
generateSitemap();
// Update sitemap every monday
Expand All @@ -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')));

Expand Down Expand Up @@ -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}`);
Expand Down