From 69f31a0a2836960c0136c22b4b7c67931285f5fd Mon Sep 17 00:00:00 2001
From: Leonardo Rossetti <lrossett@redhat.com>
Date: May 02 2022 14:18:37 +0000
Subject: [PATCH 1/3] BASE_IMAGE build arg + usage update


---

diff --git a/images/resultsdb-backend/Dockerfile b/images/resultsdb-backend/Dockerfile
index fb56b5e..35cac44 100644
--- a/images/resultsdb-backend/Dockerfile
+++ b/images/resultsdb-backend/Dockerfile
@@ -1,13 +1,13 @@
-ARG FEDORA_VERSION
+ARG BASE_IMAGE=quay.io/fedora/fedora:35
 
-FROM quay.io/fedora/fedora:${FEDORA_VERSION}
+FROM ${BASE_IMAGE}
 
 LABEL \
   name="ResultsDB Service" \
   vendor="Fedora Kube SIG developers" \
   license="MIT" \
   description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
-  usage="https://pagure.io/taskotron/resultsdb/blob/develop/f/openshift/README.md"
+  usage="https://pagure.io/kube-sig/gating-services-images"
 
 RUN dnf install -y \
   git \

From 699889599a16bbab016d84b1dc632cecc83df2a5 Mon Sep 17 00:00:00 2001
From: Leonardo Rossetti <lrossett@redhat.com>
Date: May 02 2022 19:11:53 +0000
Subject: [PATCH 2/3] resultsdb backend cs9 and fedora files


---

diff --git a/images/resultsdb-backend/Dockerfile b/images/resultsdb-backend/Dockerfile
index 35cac44..5ec76e4 100644
--- a/images/resultsdb-backend/Dockerfile
+++ b/images/resultsdb-backend/Dockerfile
@@ -1,28 +1,4 @@
-ARG BASE_IMAGE=quay.io/fedora/fedora:35
-
-FROM ${BASE_IMAGE}
-
-LABEL \
-  name="ResultsDB Service" \
-  vendor="Fedora Kube SIG developers" \
-  license="MIT" \
-  description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
-  usage="https://pagure.io/kube-sig/gating-services-images"
-
-RUN dnf install -y \
-  git \
-  python3-cachelib \
-  python3-pip \
-  python3-mod_wsgi \
-  python3-werkzeug \
-  httpd \
-  python3-psycopg2 \
-  python3-stomppy \
-  fedora-messaging \
-  resultsdb \
-  python3-resultsdb_api
-
-RUN dnf clean all
+FROM localhost/resultsdb-backend:base
 
 # fix apache config for container use
 RUN sed -i 's#^WSGISocketPrefix .*#WSGISocketPrefix /tmp/wsgi#' /usr/share/resultsdb/conf/resultsdb.conf
@@ -33,4 +9,4 @@ EXPOSE 5001
 
 ENTRYPOINT ["/entrypoint"]
 
-USER 1001
+# USER 1001
diff --git a/images/resultsdb-backend/Makefile b/images/resultsdb-backend/Makefile
index f75af81..ba6dfae 100644
--- a/images/resultsdb-backend/Makefile
+++ b/images/resultsdb-backend/Makefile
@@ -1,14 +1,16 @@
 SHELL := /bin/bash
-FEDORA_VERSION := 35
 REG := quay.io
 ORG := fedora-kube-sig
 NAME := resultsdb-backend
 TAG := latest
 IMAGE := ${REG}/${ORG}/${NAME}:${TAG}
 CRI := podman
+OS_NAME := fedora
+OS_VERSION := 35
 
 image/build:
-	@${CRI} build -t ${IMAGE} --build-arg FEDORA_VERSION=${FEDORA_VERSION} .
+	@${CRI} build -t localhost/resultsdb-backend:base -f ${OS_NAME}.Dockerfile --build-arg OS_VERSION=${OS_VERSION} .
+	@${CRI} build -t ${IMAGE} .
 
 image/push: image/build
 	@${CRI} push ${IMAGE}
diff --git a/images/resultsdb-backend/centos.Dockerfile b/images/resultsdb-backend/centos.Dockerfile
new file mode 100644
index 0000000..64d6573
--- /dev/null
+++ b/images/resultsdb-backend/centos.Dockerfile
@@ -0,0 +1,26 @@
+ARG OS_VERSION=stream9
+
+FROM quay.io/centos/centos:${OS_VERSION}
+
+LABEL \
+  name="ResultsDB Service" \
+  vendor="Fedora Kube SIG developers" \
+  license="MIT" \
+  description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
+  usage="https://pagure.io/kube-sig/gating-services-images"
+
+RUN yum install -y \
+  git \
+  python3-pip \
+  python3-mod_wsgi \
+  httpd \
+  python3-psycopg2
+
+RUN yum clean all
+
+RUN pip3 install flask flask_sqlalchemy
+
+RUN pip3 install git+https://pagure.io/taskotron/resultsdb.git
+
+COPY files/centos/resultsdb.conf /usr/share/resultsdb/conf/resultsdb.conf
+COPY files/centos/resultsdb.wsgi /usr/share/resultsdb/resultsdb.wsgi
diff --git a/images/resultsdb-backend/fedora.Dockerfile b/images/resultsdb-backend/fedora.Dockerfile
new file mode 100644
index 0000000..1203bd3
--- /dev/null
+++ b/images/resultsdb-backend/fedora.Dockerfile
@@ -0,0 +1,25 @@
+ARG OS_VERSION=35
+
+FROM quay.io/fedora/fedora:${OS_VERSION}
+
+LABEL \
+  name="ResultsDB Service" \
+  vendor="Fedora KubeDev SIG" \
+  license="MIT" \
+  description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
+  usage="https://pagure.io/kube-sig/gating-services-images"
+
+RUN dnf install -y \
+  git \
+  python3-cachelib \
+  python3-pip \
+  python3-mod_wsgi \
+  python3-werkzeug \
+  httpd \
+  python3-psycopg2 \
+  python3-stomppy \
+  fedora-messaging \
+  resultsdb \
+  python3-resultsdb_api
+
+RUN dnf clean all
diff --git a/images/resultsdb-backend/files/centos/resultsdb.conf b/images/resultsdb-backend/files/centos/resultsdb.conf
new file mode 100644
index 0000000..361fee4
--- /dev/null
+++ b/images/resultsdb-backend/files/centos/resultsdb.conf
@@ -0,0 +1,19 @@
+WSGIDaemonProcess resultsdb user=apache group=apache threads=5
+WSGIScriptAlias /resultsdb /usr/share/resultsdb/resultsdb.wsgi
+WSGISocketPrefix /tmp/wsgi
+
+<Directory /usr/share/resultsdb>
+    WSGIProcessGroup resultsdb
+    WSGIApplicationGroup %{GLOBAL}
+    WSGIScriptReloading On
+    Order deny,allow
+    Allow from all
+</Directory>
+
+#Alias /resultsdb/static /var/www/resultsdb/resultsdb/static
+
+#<Directory /var/www/resultsdb/resultsdb/static>
+#Order allow,deny
+#Allow from all
+#</Directory>
+
diff --git a/images/resultsdb-backend/files/centos/resultsdb.wsgi b/images/resultsdb-backend/files/centos/resultsdb.wsgi
new file mode 100644
index 0000000..82592a1
--- /dev/null
+++ b/images/resultsdb-backend/files/centos/resultsdb.wsgi
@@ -0,0 +1,15 @@
+# This is required for running on EL6
+import __main__
+__main__.__requires__ = ['SQLAlchemy >= 0.7', 'Flask >= 0.9', 'jinja2 >= 2.6']
+import pkg_resources
+
+# if you're running the app from a virtualenv, uncomment these lines
+#activate_this = '/var/www/resultsdb/env/bin/activate_this.py'
+#execfile(activate_this, dict(__file__=activate_this))
+#import sys
+#sys.path.insert(0,"/var/www/resultsdb/resultsdb/")
+
+import os
+os.environ['RESULTSDB_CONFIG'] = '/etc/resultsdb/settings.py'
+
+from resultsdb import app as application

From 5755705b70081eff5a2f346ddd2f2665fc4f642c Mon Sep 17 00:00:00 2001
From: Leonardo Rossetti <lrossett@redhat.com>
Date: May 02 2022 19:25:26 +0000
Subject: [PATCH 3/3] resultsdb-frontend cs9 and fedora files


---

diff --git a/images/resultsdb-frontend/Dockerfile b/images/resultsdb-frontend/Dockerfile
index a6455cc..45c5062 100644
--- a/images/resultsdb-frontend/Dockerfile
+++ b/images/resultsdb-frontend/Dockerfile
@@ -1,27 +1,4 @@
-ARG FEDORA_VERSION
-
-FROM quay.io/fedora/fedora:${FEDORA_VERSION}
-
-LABEL \
-  name="ResultsDB Frontend Service" \
-  vendor="Fedora Kube SIG" \
-  license="MIT" \
-  description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
-  usage="https://pagure.io/taskotron/resultsdb/blob/develop/f/openshift/README.md"
-
-RUN dnf install -y \
-  git \
-  python3-cachelib \
-  python3-pip \
-  python3-mod_wsgi \
-  python3-werkzeug \
-  httpd \
-  python3-psycopg2 \
-  python3-stomppy \
-  resultsdb \
-  python3-resultsdb_api
-
-RUN dnf clean all
+from localhost/resultsdb-frontend:base
 
 # TODO: resultsdb frontend rpm is outdated
 RUN pip3 install --no-deps git+https://pagure.io/taskotron/resultsdb_frontend.git@develop
diff --git a/images/resultsdb-frontend/Makefile b/images/resultsdb-frontend/Makefile
index e63e024..8a8d293 100644
--- a/images/resultsdb-frontend/Makefile
+++ b/images/resultsdb-frontend/Makefile
@@ -6,9 +6,12 @@ NAME := resultsdb-frontend
 TAG := latest
 IMAGE := ${REG}/${ORG}/${NAME}:${TAG}
 CRI := podman
+OS_NAME := fedora
+OS_VERSION := 35
 
 image/build:
-	@${CRI} build -t ${IMAGE} --build-arg FEDORA_VERSION=${FEDORA_VERSION} .
+	@${CRI} build -t localhost/resultsdb-frontend:base -f ${OS_NAME}.Dockerfile --build-arg OS_VERSION=${OS_VERSION} .
+	@${CRI} build -t ${IMAGE} .
 
 image/push: image/build
 	@${CRI} push ${IMAGE}
diff --git a/images/resultsdb-frontend/centos.Dockerfile b/images/resultsdb-frontend/centos.Dockerfile
new file mode 100644
index 0000000..c943ebc
--- /dev/null
+++ b/images/resultsdb-frontend/centos.Dockerfile
@@ -0,0 +1,24 @@
+ARG OS_VERSION=stream9
+
+FROM quay.io/centos/centos:${OS_VERSION}
+
+LABEL \
+  name="ResultsDB Service" \
+  vendor="Fedora Kube SIG developers" \
+  license="MIT" \
+  description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
+  usage="https://pagure.io/kube-sig/gating-services-images"
+
+RUN yum install -y \
+  git \
+  python3-pip \
+  python3-mod_wsgi \
+  httpd \
+  python3-psycopg2
+
+RUN yum clean all
+
+RUN pip3 install flask flask_sqlalchemy
+
+RUN pip3 install git+https://pagure.io/taskotron/resultsdb.git
+
diff --git a/images/resultsdb-frontend/fedora.Dockerfile b/images/resultsdb-frontend/fedora.Dockerfile
new file mode 100644
index 0000000..1203bd3
--- /dev/null
+++ b/images/resultsdb-frontend/fedora.Dockerfile
@@ -0,0 +1,25 @@
+ARG OS_VERSION=35
+
+FROM quay.io/fedora/fedora:${OS_VERSION}
+
+LABEL \
+  name="ResultsDB Service" \
+  vendor="Fedora KubeDev SIG" \
+  license="MIT" \
+  description="ResultsDB is a results store engine for, but not limited to, Fedora QA tools." \
+  usage="https://pagure.io/kube-sig/gating-services-images"
+
+RUN dnf install -y \
+  git \
+  python3-cachelib \
+  python3-pip \
+  python3-mod_wsgi \
+  python3-werkzeug \
+  httpd \
+  python3-psycopg2 \
+  python3-stomppy \
+  fedora-messaging \
+  resultsdb \
+  python3-resultsdb_api
+
+RUN dnf clean all
diff --git a/images/resultsdb-frontend/files/entrypoint b/images/resultsdb-frontend/files/entrypoint
index f2fa1b4..65a3684 100755
--- a/images/resultsdb-frontend/files/entrypoint
+++ b/images/resultsdb-frontend/files/entrypoint
@@ -15,5 +15,6 @@ mod_wsgi-express-3 start-server $RESULTSDB_WSGI_SCRIPT_PATH \
 --log-to-terminal \
 --access-log \
 --startup-log \
---setenv RESULTSDB_APP_SECRET mysecret
+--setenv RESULTSDB_APP_SECRET mysecret \
+--trust-proxy-header X-Forwarded-Host
 

