Configuration for
Staging
&Production
purpose
Sample domain name:
- staging.domain.com
- production.domain.com
so you must edit hosts file on local pc or server to cconfigure domain name for testing:
Windows 8.1/10
C:\Windows\System32\drivers\etc\hosts
Linux/MacOS/etc/hosts
127.0.0.1 staging.domain.com
127.0.0.1 production.domain.com
Before build remove .nuxt
directory, use rimraf
for handling remove directory not from docker entrypoint
Install
rimraf
,dotenv
npm i rimraf dotenv
Information for
staging
&production
must have, you can view on sample app onpublic_html
:
- nuxt.config.staging.js
- nuxt.config.production.js
Edit nuxt.config.js
and adding at the top file some code for get variables use dotenv
on .env
file.
const dotenv = require('dotenv')
dotenv.config()
module.exports = {
mode: 'universal',
...
}
and modify package.json file on scripts
.
...
"scripts": {
"clean": "rimraf .nuxt",
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
"build-staging": "npm run clean && nuxt build -c nuxt.config.staging.js",
"build-production": "npm run clean && nuxt build -c nuxt.config.production.js",
"start": "pm2 start ecosystem.config.js --only nuxt-app && pm2 logs",
"generate": "nuxt generate"
}
...
Remember for your express script server location depending on where you put the file.
script: "./server/index.js"
or script: "./server.js"
Same location save with project application
module.exports = {
apps : [{
name : "project-name",
exec_mode : "cluster",
instances : 2,
script: "./server/index.js",
watch: true,
env: {
"HOST": "0.0.0.0",
"PORT": 3000,
"NODE_ENV": "production"
}
}]
};