apiVersion: apps/v1
kind: Deployment
metadata:
  name: csearch.scraper
  namespace: postgres-operator
spec:
  selector:
    matchLabels:
      app: csearch.scraper
  template:
    metadata:
      labels:
        app: csearch.scraper
    spec:
      volumes:
        - name: task-pv-storage
          persistentVolumeClaim:
            claimName: csearch-pv-claim
      initContainers:
            - name: config-data
              image: ubuntu:hirsute
              command: ["/bin/sh","-c"]
              args: ["apt update; apt install -y wget tar zstd git; rm -rf /congress/temp; git clone https://github.com/unitedstates/congress.git /congress/temp; mv /congress/temp/* /congress/; cd /congress; wget https://www.dropbox.com/s/8gge1nghs81vw3i/data.tar.zst?dl=1; tar --zstd -xvf data.tar.zst?dl=1;"]
              volumeMounts:
                - mountPath: /congress
                  name: task-pv-storage
      containers:
        - name: "congress-api-sha256-1"
          image: localhost:5000/scraper
          imagePullPolicy: Always
          env:
          - name: DB_VENDOR
            value: "postgres"
          - name: DB_ADDR
            valueFrom: { secretKeyRef: { name: csearch-db-pguser-csearch-db, key: host } }
          - name: DB_URI
            valueFrom: { secretKeyRef: { name: csearch-db-pguser-csearch-db, key: uri } }
          - name: DB_PORT
            valueFrom: { secretKeyRef: { name: csearch-db-pguser-csearch-db, key: port } }
          - name: DB_DATABASE
            valueFrom: { secretKeyRef: { name: csearch-db-pguser-csearch-db, key: dbname } }
          - name: DB_USER
            valueFrom: { secretKeyRef: { name: csearch-db-pguser-csearch-db, key: user } }
          - name: DB_PASSWORD
            valueFrom: { secretKeyRef: { name: csearch-db-pguser-csearch-db, key: password } }
          volumeMounts:
            - mountPath: "/congress"
              name: task-pv-storage

