apiVersion: apps/v1
kind: Deployment
metadata:
  name: NAME-deployment
  labels:
    app.kubernetes.part-of: NAME-website
spec:
  replicas: 1
  selector:
    matchLabels:
      app: NAME-nginx
  template:
    metadata:
      labels:
        app: NAME-nginx
    spec:
      containers:
      - name: NAME-nginx
        image: nginx:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /etc/nginx 
          readOnly: true
          name: nginx-config-volume
        - mountPath: /var/log/nginx
          name: log                    
        - mountPath: /var/www/html/website
          name: content-volume
          readOnly: true
      initContainers:
      - image: domaindrivenarchitecture/c4k-website-build
        name: NAME-init-build-container
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            cpu: BUILD_CPU_REQUEST
            memory: BUILD_MEMORY_REQUEST
          limits:
            cpu: BUILD_CPU_LIMIT
            memory: BUILD_MEMORY_LIMIT
        command: ["/entrypoint.sh"]
        envFrom:
        - secretRef:
            name: NAME-secret
        env:
        - name: SHA256SUM
          value: CHECK_SUM
        - name: SCRIPTFILE
          value: SCRIPT_FILE
        volumeMounts:
        - name: content-volume
          mountPath: /var/www/html/website
        - name: hashfile-volume
          mountPath: /var/hashfile.d
      volumes:
        - name: nginx-config-volume
          configMap:
            name: NAME-configmap
            items:
              - key: nginx.conf
                path: nginx.conf
              - key: website.conf
                path: conf.d/website.conf
              - key: mime.types
                path: mime.types 
        - name: log
          emptyDir: {}
        - name: content-volume
          persistentVolumeClaim:
            claimName: NAME-content-volume
        - name: hashfile-volume
          persistentVolumeClaim:
            claimName: NAME-hashfile-volume