apiVersion: batch/v1
kind: Job
metadata:
  name: mastodon-init-db
spec:
  template:
    spec:
      initContainers:
      - name: postgres
        image: postgres:9.6.24-alpine
        command: ["sh", "-c", "until pg_isready -h postgres -p 5432; do sleep 3; done"]
      containers:
      - name: mastodon
        image: tootsuite/mastodon:v3.5.3@sha256:bd1d81cd1948cb29e9fd640c902d377fc84fe2567589aca0c290b760d57b6a2b
        command: ["./bin/rails", "db:reset"]
        env:
        - name: SAFETY_ASSURED
          value: "1"
        - name: REDIS_HOST
          value: redis
        - name: REDIS_PORT
          value: "6379"
        - name: DB_HOST
          value: postgres
        - name: DB_PORT
          value: "5432"
        - name: DB_USER
          value: postgres
        - name: DB_PASS
          value: ""
        - name: SECRET_KEY_BASE
          value: a427a53eb74fb788a9782c4290c867790ee9485c330dfc49fa3ca04f38f718205f03a77d77f50106b7cdc45f1d3b734b5476cb7da66f7f766d107f708f9e44ce
        - name: OTP_SECRET
          value: c9352eca7b8b696c0191ba675b8a2d55b0fe70ffe3d21ef1051606d6ba1d8a4a8ff3bf78fed81a7d92997bfb7579bc235992efb7f06cff6317e77f098ddf8e6e
        - name: VAPID_PRIVATE_KEY
          value: XLtm4rkyTmhTW5aJ-8OWmB32BB5uvLCppx7JPyuSnlg=
        - name: VAPID_PUBLIC_KEY
          value: BOoeifxTKxy3tSpQF9ocYXq1f64nOwx04AUaxeNRWx29fy0iqtH44NeYGmLMSYQoBanWAw4Sl5Ky5gBzBeIsT5I=
      restartPolicy: OnFailure
