apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
  namespace: reactbin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      initContainers:
        - name: migrate
          image: git.juggalol.com/juggalol/reactbin-api:v1.2.0
          command: ["alembic", "upgrade", "head"]
          workingDir: /app
          envFrom:
            - secretRef:
                name: api-env
          securityContext:
            runAsNonRoot: true
            runAsUser: 1001
      containers:
        - name: api
          image: git.juggalol.com/juggalol/reactbin-api:v1.2.0
          ports:
            - containerPort: 8000
          envFrom:
            - secretRef:
                name: api-env
          env:
            - name: API_DOCS_ENABLED
              value: "false"
          livenessProbe:
            httpGet:
              path: /api/v1/health
              port: 8000
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /api/v1/health
              port: 8000
            initialDelaySeconds: 5
            periodSeconds: 10
          securityContext:
            runAsNonRoot: true
            runAsUser: 1001
