apiVersion: v1
items:
- apiVersion: v1
  kind: BuildConfig
  metadata:
    labels:
      build: release-monitoring-web-build
    name: release-monitoring-web-build
  spec:
    runPolicy: Serial
    source:
      dockerfile: |-
        FROM fedora:29
        LABEL \
          name="release-monitoring-web" \
          vendor="Fedora Infrastructure" \
          license="MIT"
        RUN dnf install -y --enablerepo=updates-testing \
                git \
                httpd \
                graphviz \
                python3-alembic \
                python3-blinker \
                python3-dateutil \
                python3-fedmsg \
                fedora-messaging \
                python3-fedora-messaging \
                python3-flask \
                python3-flask-wtf \
                python3-flask-login \
                python3-flask-restful \
                python3-flask-openid \
                python3-openid \
                python3-pip \
                python3-psycopg2 \
                python3-setuptools \
                python3-sphinxcontrib-httpdomain \
                python3-social-auth-app-flask-sqlalchemy \
                python3-straight-plugin \
                python3-sqlalchemy \
                python3-pytoml \
                python3-wtforms \
                python3-mod_wsgi && \
            dnf autoremove -y && \
            dnf clean all -y
        RUN pip-3 install sqlalchemy_schemadisplay
        RUN git clone https://github.com/release-monitoring/anitya.git && \
                pushd anitya && \
{% if env == 'staging' %}
                git checkout staging && \
{% else %}
                git checkout production && \
{% endif %}
                python3 setup.py install && \
                pushd docs && \
                mkdir -p images && \
                python3 generate_db_schema && \
                sphinx-build-3 -b html . _build/html && \
                mkdir -p ../anitya/static/docs/ && \
                cp -r _build/html/* ../anitya/static/docs/ && \
                popd && \
                python3 setup.py install && \
                rm -f /usr/local/bin/anitya_cron.py && \
                cp files/anitya_cron.py /usr/local/bin/ && \
                pip-3 install . && \
                pushd anitya_schema && \
                pip-3 install . && \
                popd && \
                popd && \
                rm -rf anitya
        RUN rm /etc/fedmsg.d/*py
        RUN mkdir /httpdir
        RUN chmod 777 /httpdir
        RUN mkdir -p /etc/pki/fedmsg/
        RUN ln -sf /etc/pki/fedmsg/key/fedmsg-release-monitoring.key /etc/pki/fedmsg/release-monitoring.key
        RUN ln -sf /etc/pki/fedmsg/crt/fedmsg-release-monitoring.crt /etc/pki/fedmsg/release-monitoring.crt
        EXPOSE 8080
        EXPOSE 9940
      type: Dockerfile
      git:
        uri: https://github.com/release-monitoring/anitya.git
{% if env == 'staging' %}
        ref: staging
{% else %}
        ref: production
{% endif %}
    strategy:
      type: Docker
    output:
      to:
        kind: ImageStreamTag
        name: release-monitoring-web:latest
    triggers:
{% if stg_anitya_github_secret is defined and env == 'staging' %}
    - type: GitHub
      github:
        secret: "{{ stg_anitya_github_secret }}"
{% elif anitya_github_secret is defined and env == 'production' %}
    - type: GitHub
      github:
        secret: "{{ anitya_github_secret }}"
{% endif %}
    - type: ConfigChange
    - type: ImageChange
kind: List
metadata: {}
