apiVersion: apps/v1
kind: Deployment
metadata:
  name: longroute-web
  labels:
    app: longroute-web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: longroute-web
  template:
    metadata:
      labels:
        app: longroute-web
    spec:
      imagePullSecrets:
      - name: gitlab-token
      initContainers:
      - name: init
        image: CI_REGISTRY_IMAGE:CI_COMMIT_TAG
        command:
        - cp
        - -a
        - /public
        - /usr/share/nginx/html
        volumeMounts:
          - name: web
            mountPath: /usr/share/nginx
      containers:
      - name: web
        image: nginx:1.25.3-bookworm
        ports:
         - containerPort: 80
        resources:
          requests:
            memory: "20M"
            cpu: 20m
          limits:
            memory: "4000M"
            cpu: 2000m
        readinessProbe:
          httpGet:
            path: "/"
            port: 80
          initialDelaySeconds: 15
          periodSeconds: 30
        livenessProbe:
          httpGet:
            path:  "/"
            port: 80
          initialDelaySeconds: 120
          periodSeconds: 60
        volumeMounts:
        - name: web
          mountPath: /usr/share/nginx/html
          subPath: html
      volumes:
      - name: web
        emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: longroute-web
spec:
  type: ClusterIP
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: longroute-web
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-production
  name: longroute-ingress
spec:
  ingressClassName: nginx
  rules:
    - host: HOST
      http:
        paths:
          - path: "/"
            pathType: Prefix
            backend:
              service:
                name: longroute-web
                port:
                  number: 80
  tls:
    - hosts:
        - HOST
      secretName: longroute-ingress-tls-secret