apiVersion: apps/v1
kind: Deployment
metadata:
  name: edusoho-web
  namespace: edusoho
spec:
  selector:
    matchLabels:
      app: edusoho-web
  template:
    metadata:
      labels:
        app: edusoho-web
    spec:
      containers:
        - name: edusoho-web
          image: registry.cn-shanghai.aliyuncs.com/hsin/edusoho-init:21.1.6
          resources:
            limits:
              memory: "512Mi"
              cpu: "500m"
          ports:
            - containerPort: 80
              name: nginx-port
          volumeMounts:
            - mountPath: /var/www/edusoho/
              name: web-pvc
          lifecycle:
            postStart:
              exec:
                command: ["sh", "-c", 'if [ -d "/var/www/edusoho/init" ]; then while [ ! -f "/var/www/edusoho/init/OK" ]; do echo "wait init..."; sleep 1; done; else mkdir "/var/www/edusoho/init"; mv /var/www/edusoho-init/* "/var/www/edusoho/" && touch /var/www/edusoho/init/OK || exit 2; fi']
            preStop:
              exec:
                command: ["sh", "-c", "/usr/local/nginx/sbin/nginx -s stop"]
          readinessProbe:
            initialDelaySeconds: 10
            httpGet:
              path: "/"
              port: nginx-port
          # livenessProbe:
          #   initialDelaySeconds: 30
          #   timeoutSeconds: 3
          #   periodSeconds: 30
          #   httpGet:
          #     path: "/"
          #     port: nginx-port
      volumes:
        - name: web-pvc
          persistentVolumeClaim:
            claimName: web-pvc
