From c26131782c907a24870d8efc2e420abd78761f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20L=C3=B3pez?= Date: Wed, 8 Nov 2023 15:39:37 -0300 Subject: [PATCH] ci: script to run using pm2 --- README.md | 14 ++++++++++++++ next.config.js | 3 ++- pm2.config.js | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 pm2.config.js diff --git a/README.md b/README.md index fd2aa40..7b71d40 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,17 @@ npm run start 1. [Install Docker](https://docs.docker.com/get-docker/) on your machine. 2. Build the container: `docker build -t er-docker .`. 3. Run the container: `docker run -p 3000:3000 er-docker`. + +### With pm2 +#### Install pm2 +```bash +npm install pm2 -g +``` +#### Build the Next.js app +```bash +npm run build:next +``` +#### Start the node.js server with pm2 +``` +pm2 start pm2.config.js +``` diff --git a/next.config.js b/next.config.js index 2679637..c4f74ab 100644 --- a/next.config.js +++ b/next.config.js @@ -24,5 +24,6 @@ const withNextra = require("nextra")({ }); module.exports = withNextra({ - output: "standalone", + // if using Docker, need to use standalone + // output: "standalone", }); diff --git a/pm2.config.js b/pm2.config.js new file mode 100644 index 0000000..490f47b --- /dev/null +++ b/pm2.config.js @@ -0,0 +1,14 @@ +module.exports = { + apps: [ + { + name: 'erdoc playground', + script: 'npm', + args: 'start', + instances: 2, + exec_mode: 'cluster', + env: { + PORT: 3000 + } + } + ] +}