start to handle environment variables
This commit is contained in:
parent
ece6c8e450
commit
28c91b7d05
4 changed files with 15 additions and 5 deletions
|
@ -17,6 +17,7 @@ CMD ["npm", "start"]
|
|||
|
||||
FROM development as build
|
||||
ENV NODE_ENV production
|
||||
COPY .env ./
|
||||
RUN npm run build
|
||||
|
||||
FROM base as production
|
||||
|
@ -25,7 +26,6 @@ COPY package.json package-lock.json ./
|
|||
RUN npm install --production
|
||||
RUN npm rebuild node-sass
|
||||
RUN npm install pm2 -g
|
||||
COPY index.js ./
|
||||
COPY ecosystem.json ./
|
||||
COPY index.js ecosystem.json .env ./
|
||||
COPY --from=build /usr/src/app/dist ./dist
|
||||
CMD ["pm2-runtime", "ecosystem.json"]
|
||||
|
|
8
index.js
8
index.js
|
@ -1,9 +1,15 @@
|
|||
let parsed = require('dotenv').config();
|
||||
// let parsed = require('dotenv').config();
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
try {
|
||||
require('dotenv').config();
|
||||
} catch(error) {
|
||||
console.log('.env file does not exist. Assuming environment variables are pre-loaded.');
|
||||
}
|
||||
process.env.webpackAssets = JSON.stringify(require('./dist/static/manifest.json'));
|
||||
process.env.webpackChunkAssets = JSON.stringify(require('./dist/static/chunk-manifest.json'));
|
||||
require('./dist/server.bundle.js');
|
||||
} else {
|
||||
let parsed = require('dotenv').config();
|
||||
require('babel-register')({
|
||||
"plugins": [
|
||||
[
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FROM nginx:1.13.12
|
||||
|
||||
RUN mkdir -p /etc/nginx/sites-enabled
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
RUN mkdir /etc/nginx/sites-enabled
|
||||
COPY alpha.editor.p5js.org.conf /etc/nginx/sites-enabled
|
|
@ -6,7 +6,11 @@ const cssnext = require('postcss-cssnext');
|
|||
const postcssFocus = require('postcss-focus');
|
||||
const postcssReporter = require('postcss-reporter');
|
||||
const cssnano = require('cssnano');
|
||||
try {
|
||||
require('dotenv').config();
|
||||
} catch (error) {
|
||||
console.log('.env file does not exist. Assuming environment variables are pre-loaded.');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
|
|
Loading…
Reference in a new issue