apiVersion: apps/v1
kind: Deployment
metadata:
  name: scoutplan-sidekiq
spec:
  replicas: 1
  selector:
    matchLabels:
      app: scoutplan-sidekiq
  minReadySeconds: 5
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 5
      maxUnavailable: 1
  template:
    metadata:
      labels:
        app: scoutplan-sidekiq
    spec:
      containers:
        - name: scoutplan-sidekiq
          image: registry.digitalocean.com/scoutplan/app

          # change to bundle exec as per https://github.com/hotwired/turbo-rails/issues/285#issuecomment-1004395809
          command:
            - bundle
            - exec
            - sidekiq
          imagePullPolicy: "Always"
          # readinessProbe:
          #   httpGet:
          #     path: /
          #     port: 7433
          #   initialDelaySeconds: 60
          #   timeoutSeconds: 10
          env:
            - name: GITHUB_RUN_NUMBER
              value: "github-run-number"          
            - name: DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: scoutplan-production
                  key: DATABASE_PASSWORD
            - name: RAILS_MASTER_KEY
              valueFrom:
                secretKeyRef:
                  name: scoutplan-production
                  key: RAILS_MASTER_KEY                  
            - name: SECRET_KEY_BASE
              valueFrom:
                secretKeyRef:
                  name: scoutplan-production
                  key: SECRET_KEY_BASE
            - name: SKYLIGHT_AUTHENTICATION
              valueFrom:
                secretKeyRef:
                  name: scoutplan-production
                  key: SKYLIGHT_AUTHENTICATION
            - name: SMTP_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: scoutplan-production
                  key: SMTP_PASSWORD
            - name: MAPBOX_TOKEN
              valueFrom:
                secretKeyRef:
                  name: scoutplan-production
                  key: MAPBOX_TOKEN
            - name: DO_STORAGE_SECRET
              valueFrom:
                secretKeyRef:
                  name: scoutplan-production
                  key: DO_STORAGE_SECRET
          envFrom:
          - configMapRef:
              name: scoutplan-production-config
          ports:
            - containerPort: 3000
