{% macro load_file(filename) %}{% include filename %}{%- endmacro -%}
---
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: maubot-build
  labels:
    app: maubot
    build: maubot
spec:
  runPolicy: Serial
  source:
    dockerfile: |-
      FROM fedora:38
      RUN dnf -y install python3-pip python3-gssapi git && dnf -y clean all
      RUN pip install maubot[encryption] python-slugify httpx httpx_gssapi jinja2 fedora-messaging meetbot-messages pydantic maubot-fedora-messages backoff arrow python-gitlab
      RUN \
        curl https://raw.githubusercontent.com/fedora-infra/matrix-bots/main/install-plugins-from-git.py -o /usr/local/bin/install-maubot-plugins && \
        chmod +x /usr/local/bin/install-maubot-plugins && \
        mkdir /maubot && \
        for plugin in maubot-fedora maubot-adminclient maubot-meetings maubot-webhook maubot-pagure-notifications maubot-gitlab; do \
          install-maubot-plugins -o /maubot -b {{ (env == "production")|ternary("stable", "staging") }} https://github.com/fedora-infra/${plugin}; \
        done;
      WORKDIR /maubot
      ENV KRB5_CONFIG=/etc/ipa/krb5.conf
      ENTRYPOINT /usr/bin/python3 -m maubot -c /config/config.yml
    type: Dockerfile
  strategy:
    type: Docker
    dockerStrategy:
      noCache: false
      from:
        kind: ImageStreamTag
        name: fedora:38
  output:
    to:
      kind: ImageStreamTag
      name: maubot:latest
  triggers:
    - type: ConfigChange
    - type: ImageChange
    - type: Generic
      generic:
        secret: "{{ (env == 'production')|ternary(maubot_prod_github_secret, maubot_stg_github_secret) }}"
