# ==============================
# Hanko
# ==============================
apiVersion: batch/v1
kind: Job
metadata:
  name: hanko-migrate
spec:
  template:
    spec:
      restartPolicy: OnFailure
      containers:
        - name: migrate
          image: ghcr.io/teamhanko/hanko:v2.1.2
          command: ["hanko", "migrate", "up"]
          resources:
            limits:
              memory: "128Mi"
              cpu: "500m"
            requests:
              memory: 64Mi
              cpu: 20m
          env:
            - name: DATABASE_URL
              value: postgres://dev:dev@postgres:5432/backend_db?sslmode=disable&search_path=public
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hanko
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hanko
  template:
    metadata:
      labels:
        app: hanko
    spec:
      containers:
        - name: hanko
          image: ghcr.io/teamhanko/hanko:v2.1.2
          command: ["hanko", "serve", "all"]
          resources:
            limits:
              memory: "128Mi"
              cpu: "500m"
            requests:
              memory: 64Mi
              cpu: 20m
          env:
            - name: DATABASE_URL
              value: postgres://dev:dev@postgres:5432/backend_db?sslmode=disable&search_path=public
          ports:
            - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: hanko
spec:
  selector:
    app: hanko
  ports:
    - port: 8080
      targetPort: 8080
