apiVersion: batch/v1
kind: Job
metadata:
  name: setup
spec:
  template:
    metadata:
      name: setup
    spec:
      containers:
      - name: setup
        image: tzumby/rails-app-alpine:latest
        args: ["rake db:create && rake db:migrate"]
        env:
        - name: DATABASE_NAME
          value: "rails-kube-demo_production"
        - name: DATABASE_PORT
          value: "5432"
        - name: DATABASE_URL
          value: "postgres"
        - name: DATABASE_USER
          valueFrom:
            secretKeyRef:
              name: "db-user"
              key: "username"
        - name: DATABASE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: "db-user-pass"
              key: "password"
        - name: REDIS_URL
          value: "redis"
        - name: REDIS_PORT
          value: "6379"
        - name: RAILS_ENV
          value: "production"
        - name: SECRET_KEY_BASE
          valueFrom:
            secretKeyRef:
              name: "secret-key-base"
              key: "secret-key-base"
      restartPolicy: Never
