apiVersion: apps/v1
kind: Deployment
metadata:
  name: drupal
  labels:
    app: drupal
spec:
  replicas: 1
  selector:
    matchLabels:
      app: drupal
  template:
    metadata:
      labels:
        app: drupal
    spec:
      initContainers:
        - name: init-sites-volume
          image: drupal:8.6
          volumeMounts:
            - mountPath: /data
              name: pvc
          command:
            - /bin/bash
            - -c
          args:
            - "cp -r /var/www/html/sites/ /data/; chown www-data:www-data /data/ -R"
      volumes:
        - name: pvc
          persistentVolumeClaim:
            claimName: drupal-pvc
      containers:
        - name: drupal
          image: drupal:8.6
          volumeMounts:
            - mountPath: /var/www/html/modules
              name: pvc
              subPath: modules
            - mountPath: /var/www/html/profiles
              name: pvc
              subPath: profiles
            - mountPath: /var/www/html/sites
              name: pvc
              subPath: sites
            - mountPath: /var/www/html/themes
              name: pvc
              subPath: themes
