#15 Create a production ready Dockerfile
Closed 4 years ago by rlim. Opened 4 years ago by rlim.

file modified
+57 -9
@@ -1,11 +1,59 @@

- FROM fedoraqa/flask-base:24

+ # This will produce an image to be used in Openshift

+ # Build should be triggered from repo root like:

+ # docker build -f openshift/Dockerfile \

+ #              --tag <IMAGE_TAG>

  

- RUN dnf install -y python-resultsdb_api && dnf clean all

- COPY . /usr/src/resultsdb_frontend

- COPY ./docker_data/settings.py /usr/src/resultsdb_frontend/conf/

- WORKDIR /usr/src/resultsdb_frontend

- EXPOSE 5002

- ENV DEV true

- RUN pip install -r requirements.txt

+ FROM registry.fedoraproject.org/fedora:32

+ LABEL \

+     name="ResultsDB_frontend application" \

+     vendor="ResultsDB_frontend developers" \

+     license="GPLv2+" \

+     description="ResultsDB_frontend is a simple application that allows browsing the data stored inside ResultsDB." \

+     usage="" \

+     build-date=""

+ 

+ USER root

+ COPY ./resultsdb_frontend.spec /opt/app-root/src/resultsdb_frontend/resultsdb_frontend.spec

+ 

+ # install dependencies defined in RPM spec file

+ RUN dnf -y install findutils rpm-build python3-pip python3-mod_wsgi httpd python3-psycopg2 python3-stomppy \

+     && rpm --query --requires --specfile /opt/app-root/src/resultsdb_frontend/resultsdb_frontend.spec | xargs -d '\n' dnf -y install

+ 

+ COPY . /opt/app-root/src/resultsdb_frontend/

+ # install using --no-deps option to ensure nothing comes from PyPi

+ RUN pip3 install --no-deps /opt/app-root/src/resultsdb_frontend

+ 

+ # fix apache config for container use

+ RUN sed -i 's#^WSGISocketPrefix .*#WSGISocketPrefix /tmp/wsgi#' /opt/app-root/src/resultsdb_frontend/conf/resultsdb_frontend.conf

+ 

+ # config files

+ RUN install -d /usr/share/resultsdb_frontend/conf \

+     && install -p -m 0644 /opt/app-root/src/resultsdb_frontend/conf/resultsdb_frontend.conf /usr/share/resultsdb_frontend/conf/ \

+     && install -p -m 0644 /opt/app-root/src/resultsdb_frontend/conf/resultsdb_frontend.wsgi /usr/share/resultsdb_frontend/ \

+     && install -d /etc/resultsdb_frontend \

+     && install -p -m 0644 /opt/app-root/src/resultsdb_frontend/conf/resultsdb_frontend.conf /etc/httpd/conf.d/

  

- CMD ["python", "runapp.py"]

+ RUN sudo touch /etc/resultsdb_frontend/settings.py

+ RUN sudo echo "SECRET_KEY = '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1`'" >> /etc/resultsdb_frontend/settings.py

+ 

+ #RUN echo "RDB_URL = 'http://localhost:5001/api/v2.0'" >> /etc/resultsdb_frontend/settings.py #######################################

+ RUN echo "RDB_URL = 'http://resultsdb:5001/api/v2.0'" >> /etc/resultsdb_frontend/settings.py #######################################

+ 

+ 

+ # clean up

+ RUN rm -rf /opt/app-root/src/resultsdb_frontend \

+     && dnf -y autoremove findutils rpm-build \

+     && dnf clean all

+ 

+ # EXPOSE 5002/tcp

+ EXPOSE 5002

+ CMD ["mod_wsgi-express-3", "start-server", "/usr/share/resultsdb_frontend/resultsdb_frontend.wsgi", \

+     "--user", "apache", "--group", "apache", \

+     "--port", "5002", "--threads", "5", \

+     "--include-file", "/etc/httpd/conf.d/resultsdb_frontend.conf", \

+     "--log-level", "info", \

+     "--log-to-terminal", \

+     "--access-log", \

+     "--startup-log" \

+ ]

+ USER 1001:0

file modified
+1 -1
@@ -1,4 +1,4 @@

- WSGIDaemonProcess resultsdb_frontend user=apache group=apache threads=5

+ WSGIDaemonProcess resultsdb_frontend user=apache group=apache threads=5 home=/usr/share/resultsdb_frontend

  WSGIScriptAlias /resultsdb_frontend /usr/share/resultsdb_frontend/conf/resultsdb_frontend.wsgi

  WSGISocketPrefix run/wsgi

  

JIRA: https://projects.engineering.redhat.com/browse/CWFHEALTH-530

Contribute a production ready Dockerfile for ResultsDB frontend.

Pull-Request has been closed by rlim

4 years ago