apiVersion: v1
kind: BuildConfig
metadata:
  name: "greenwave-docker-build"
  labels:
    environment: "greenwave"
spec:
  runPolicy: Serial
  source:
    dockerfile: |-
      # See imagestream.yml for the definition
      FROM greenwave-upstream:latest

      # fedmsg needs a username.
      ENV USER=greenwave

      # Become root during build to chmod
      USER 0

      # create a symlink for configuring the fedmsg consumers.
      RUN ln -sfn /etc/fedmsg-greenwave.d/greenwave.py /etc/fedmsg.d/zz_greenwave.py

      # And another two for putting the certs in place.
      RUN mkdir -p /etc/pki/fedmsg/
      RUN ln -sf /etc/pki/fedmsg/key/fedmsg-greenwave.key /etc/pki/fedmsg/greenwave.key
      RUN ln -sf /etc/pki/fedmsg/crt/fedmsg-greenwave.crt /etc/pki/fedmsg/greenwave.crt

      # Make sure fedmsg can write its CRL.
      RUN chmod 777 /var/run/fedmsg/

      # Become non-root again
      USER 1001
      ENTRYPOINT docker/install-ca.sh && gunicorn-3 --workers 8 --timeout 127 --bind 0.0.0.0:8080 --access-logfile=- --enable-stdio-inheritance greenwave.wsgi:app
  strategy:
    type: Docker
    dockerStrategy:
      from:
        kind: "ImageStreamTag"
        name: "greenwave-upstream:latest"
  triggers:
      - type: ImageChange
  output:
    to:
      kind: ImageStreamTag
      name: greenwave:latest
