apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    keel.sh/policy: force
    keel.sh/match-tag: "true"
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      component: web
  template:
    metadata:
      labels:
        component: web
    spec:
      securityContext:
        runAsUser: 1000
        runAsGroup: 1000
        fsGroup: 1000
      initContainers:
      - name: wait-for-mongodb
        image: mongo
        command: ['sh', '-c',
          'until echo "db.runCommand(\"ping\").ok" | mongo $(MONGODB_SERVICE):27017/test --quiet;
          do echo waiting for database; sleep 2; done;']
        env:
        - name: MONGODB_SERVICE
          value: $(MONGODB_SERVICE)
      containers:
      - name: web
        image: inko/course-mapper:latest
        ports:
        - containerPort: 8000
        readinessProbe:
          httpGet:
            path: /
            port: 8000
        livenessProbe:
          exec:
            command: ['ls', '/home/node/app/public/resources/']
          initialDelaySeconds: 5
          periodSeconds: 15
        env:
        - name: NODE_ENV
          value: production
        - name: DATABASE
          value: $(MONGODB_SERVICE)/course_mapper
        - name: PORT
          value: "8000"
        volumeMounts:
        - mountPath: /home/node/app/public/resources
          name: web
          subPath: resources
        - mountPath: /home/node/app/public/pa
          name: web
          subPath: pa
        - mountPath: /home/node/app/public/img/courses
          name: web
          subPath: img/courses
        resources:
          requests:
            memory: 110Mi
            cpu: 100m
          limits:
            memory: 256Mi
            cpu: 1
      volumes:
      - name: web
        persistentVolumeClaim:
          claimName: web
