apiVersion: apps/v1
kind: Deployment
metadata:
  name: server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: server
  template:
    metadata:
      labels:
        app: server
    spec:
      volumes:
        - name: fabricfiles
          persistentVolumeClaim:
            claimName: fabric-pvc
        - name: serverfiles
          persistentVolumeClaim:
            claimName: server-pvc
      containers:
        - name: server
          image: conglt/study-chain-server
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
          env:
            - name: MONGODB_URI
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: MONGODB_URI
            - name: MONGODB_CONTAINER
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: MONGODB_CONTAINER
            - name: SECRET_JWT
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: SECRET_JWT
            - name: NODE_ENV
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: NODE_ENV
            - name: ADMIN_ACADEMY_USERNAME
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: ADMIN_ACADEMY_USERNAME
            - name: ADMIN_ACADEMY_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: ADMIN_ACADEMY_PASSWORD
            - name: ADMIN_STUDENT_USERNAME
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: ADMIN_STUDENT_USERNAME
            - name: ADMIN_STUDENT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: ADMIN_STUDENT_PASSWORD
            - name: TEACHER_DEFAULT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysecret
                  key: TEACHER_DEFAULT_PASSWORD
          volumeMounts:
            - mountPath: /network
              name: fabricfiles
            - mountPath: /app/cli/wallet
              name: serverfiles
