apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-demo
  labels:
    purpose: demonstrate-command
spec:
  selector:
    matchLabels:
      app: nginx-demo
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx-demo
    spec:
      containers:
      - name: nginx-demo-container
        image: nginx
        env:
        - name: WEB_REVERSE_PROXY_PORT
          value: "3005"
        - name: NGINX_PORT
          value: "80"
        ports:
        - containerPort: 80
        command: ["/bin/bash"]
        args: ["-c", "envsubst < /etc/nginx/templates/app.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"]
        volumeMounts:
          - name: nginx-configs
            mountPath: /etc/nginx/templates
      # Load the configuration files for nginx
      volumes:
        - name: nginx-configs
          configMap:
            name: nginx-config