Skip to content

Commit

Permalink
Add local mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
oscrx committed Aug 7, 2023
1 parent 36b304e commit 887a911
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
58 changes: 58 additions & 0 deletions charts/drinkn/templates/mongo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{- if .Values.pr.enabled }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb
spec:
replicas: 1
serviceName: mongodb
selector:
matchLabels:
app: mongodb
template:
metadata:
labels:
app: mongodb
spec:
containers:
- name: mongodb
image: mongo:4.4.18
ports:
- containerPort: 27017
env:
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
name: drinkn-env
key: DB_USERNAME
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: drinkn-env
key: DB_PASSWORD
volumeMounts:
- name: mongo-storage
mountPath: /data/db
volumeClaimTemplates:
- metadata:
name: mongo-storage
spec:
storageClassName: ceph-filesystem
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: mongodb
spec:
selector:
app: mongodb
ports:
- protocol: TCP
port: 27017
targetPort: 27017
{{- end }}
16 changes: 15 additions & 1 deletion charts/drinkn/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,19 @@ spec:
JWTSECRET: AgALWkvAQhvlK6ISn521rfVHmu8R9k90dNT+0xU/EkUGh6m1egHkg53LdknlCM3fwJ6Yk7Zp8eaZ6m7nHIJzRCbn8wLrGQZzoPOFa9LgvRXxXL6CPNBUzzypU8uFNzUuSYBYY+rCSofczOavdrR+JEqPuYiRse7jdtdv0dAC1rTROtRfdkF36B9Nh9QZGtuc8SR6EeLgCoqfC28UiEQVCatAZKAWuXAfQ0HrHWcHps1JARw12FhL/qZITLYxkDD5R/45us7QHWJzlQ1IJd6O3ZuAeWiRLavnOSBy4EFfKUhv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s3jBKfUFq/caTo8fWCvvtBCzlUYCGMkwaHMz1mlPMejAK3cDd8YKgF43fzhef+k86fPp460r55AOK7mqIFtqOWXymbFrRqcG+zqkHFSJRr6tCrYrTNicDve91WL64hIQ7zrmppDrT507+qJPpbxDUYGTrZedo1R05GR5vfx7Eiax2yTB5Yo6vNutaoG3QI/V+ZBA++BIFcGw0Cfiunto/Q0A==
{{- else }}
# TODO dev secret
---
apiVersion: v1
kind: Secret
metadata:
name: drinkn-env
stringData:
APPSECRET: test
DB_HOST: mongodb.srv.cluster.local
DB_NAME: test
DB_USERNAME: test
DB_PASSWORD: test
DEFAULT_USER: test
DEFAULT_PASS: test
JWTSECRET: test
NO_SRV: "true"
{{- end }}
9 changes: 8 additions & 1 deletion pils/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
if (process.env.NODE_ENV !== 'production') require('dotenv').config() // use the .env file for this
require('./setup')
const connectionString = `mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}/${process.env.DB_NAME}`

if (process.env.NO_SRV) {
const mongoProtocol = 'mongodb'
} else {
const mongoProtocol = 'mongodb+srv'
}

const connectionString = `${mongoProtocol}://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}/${process.env.DB_NAME}`

const express = require('express')
const history = require('connect-history-api-fallback')
Expand Down

0 comments on commit 887a911

Please sign in to comment.