Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Use pm2 in production docker image (#1331)
sarayourfriendd915743af7bb
diff --git a/Dockerfile b/Dockerfileindex 64143b41d..935763078 100644--- a/Dockerfile+++ b/Dockerfile@@ -2,7 +2,7 @@ FROM node:16-alpineARG PNPM_VERSION-RUN npm install -g pnpm@${PNPM_VERSION}+RUN npm install -g pnpm@${PNPM_VERSION} [email protected]USER node@@ -29,17 +29,15 @@ RUN pnpm i18n# build the application and generate a distribution packageRUN pnpm build:only+COPY ecosystem.config.js /home/node/app/ecosystem.config.js+# set app serving to permissive / assignedENV NUXT_HOST=0.0.0.0-# set app port-ENV NUXT_PORT=8443-# set application portENV PORT=8443# expose port 8443 by defaultEXPOSE 8443-# run the application in static mode-ENTRYPOINT ["pnpm", "run", "start"]+CMD ["pm2-runtime", "start", "ecosystem.config.js"]diff --git a/ecosystem.config.js b/ecosystem.config.jsnew file mode 100644index 000000000..b41114008--- /dev/null+++ b/ecosystem.config.js@@ -0,0 +1,12 @@+module.exports = {+ apps: [+ {+ name: 'openverse-frontend',+ exec_mode: 'cluster',+ instances: 'max',+ cwd: '/home/node/app',+ script: './node_modules/nuxt/bin/nuxt.js',+ args: `start -c ${process.cwd()}/nuxt.config.ts`,+ },+ ],+}diff --git a/nuxt.config.ts b/nuxt.config.tsindex 22919a5ff..482a467f2 100644--- a/nuxt.config.ts+++ b/nuxt.config.ts@@ -140,6 +140,9 @@ const config: NuxtConfig = {},},srcDir: 'src/',+ // Necessary to fix pm2 + nuxt issues+ rootDir: process.cwd(),+ buildDir: process.cwd() + '/.nuxt/',modern: 'client',server: {port: process.env.PORT || 8443,