update fetch example scripts connection to mongodb, add pulling env variables from secret to kubernetes config

This commit is contained in:
Cassie Tarakajian 2018-09-07 15:29:47 -04:00
parent 545d4aec5f
commit 8be04ac817
3 changed files with 12 additions and 4 deletions

View file

@ -92,7 +92,11 @@ spec:
- name: fetch-examples - name: fetch-examples
image: index.docker.io/catarak/p5.js-web-editor:latest image: index.docker.io/catarak/p5.js-web-editor:latest
command: ["npm", "run", "fetch-examples:prod"] command: ["npm", "run", "fetch-examples:prod"]
restartPolicy: OnFailure imagePullPolicy: Always
envFrom:
- secretRef:
name: web-editor-credentials
restartPolicy: Never
--- ---
# cronjob for generative gestaltung p5.js examples # cronjob for generative gestaltung p5.js examples
apiVersion: batch/v1beta1 apiVersion: batch/v1beta1
@ -109,4 +113,8 @@ spec:
- name: fetch-examples-gg - name: fetch-examples-gg
image: index.docker.io/catarak/p5.js-web-editor:latest image: index.docker.io/catarak/p5.js-web-editor:latest
command: ["npm", "run", "fetch-examples-gg:prod"] command: ["npm", "run", "fetch-examples-gg:prod"]
restartPolicy: OnFailure imagePullPolicy: Always
envFrom:
- secretRef:
name: web-editor-credentials
restartPolicy: Never

View file

@ -82,7 +82,7 @@ if (process.env.NODE_ENV === 'production' && process.env.MONGO_RW_USERNAME && pr
} else { } else {
mongoConnectionString = process.env.MONGO_URL; mongoConnectionString = process.env.MONGO_URL;
} }
mongoose.connect(mongoConnectionString); mongoose.connect(mongoConnectionString, { useMongoClient: true });
mongoose.connection.on('error', () => { mongoose.connection.on('error', () => {
console.error('MongoDB Connection Error. Please make sure that MongoDB is running.'); console.error('MongoDB Connection Error. Please make sure that MongoDB is running.');
process.exit(1); process.exit(1);

View file

@ -53,7 +53,7 @@ if (process.env.NODE_ENV === 'production' && process.env.MONGO_RW_USERNAME && pr
mongoConnectionString = process.env.MONGO_URL; mongoConnectionString = process.env.MONGO_URL;
} }
mongoose.connect(mongoConnectionString); mongoose.connect(mongoConnectionString, { useMongoClient: true });
mongoose.connection.on('error', () => { mongoose.connection.on('error', () => {
console.error('MongoDB Connection Error. Please make sure that MongoDB is running.'); console.error('MongoDB Connection Error. Please make sure that MongoDB is running.');
process.exit(1); process.exit(1);