start to handle environment variables

This commit is contained in:
Cassie Tarakajian 2018-06-07 14:49:17 -07:00
parent 0857a52326
commit 6dd92a1573
4 changed files with 15 additions and 5 deletions

View File

@ -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"]

View File

@ -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": [
[

View File

@ -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

View File

@ -6,7 +6,11 @@ const cssnext = require('postcss-cssnext');
const postcssFocus = require('postcss-focus');
const postcssReporter = require('postcss-reporter');
const cssnano = require('cssnano');
require('dotenv').config();
try {
require('dotenv').config();
} catch (error) {
console.log('.env file does not exist. Assuming environment variables are pre-loaded.');
}
module.exports = {
devtool: 'source-map',