#19 Create a production ready Dockerfile
Merged 4 years ago by frantisekz. Opened 4 years ago by rlim.
taskotron/ rlim/resultsdb_frontend dockerize_resultsdb_frontend  into  develop

file modified
+47 -8
@@ -1,11 +1,50 @@ 

- 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 Dockerfile --tag <IMAGE_TAG>

+ 

+ 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

+ 

+ ARG DEFAULT_LOG_LEVEL=info

+ ENV LOG_LEVEL=$DEFAULT_LOG_LEVEL

+ 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 \

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

+     && dnf -y clean all

+  

+ 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/

  

- 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

  

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

+ 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", "${LOG_LEVEL}", \

+     "--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: CWFHEALTH-530

Repushing a new PR as https://pagure.io/taskotron/resultsdb_frontend/pull-request/16 was giving me some issues. The requested changes from the previous PR have been incorporated into this one

@mprahl @frantisekz
Updated PR for the Dockerfile; I submitted a new request because I was having some trouble with my forked repo, but I got it resolved!

Could you please add && dnf -y clean all at the end so we keep this container image layer smaller (i.e. without the dnf cache).

Could you please make the log level an environment variable so it is configurable?

3 new commits added

  • Create a Production ready Dockerfile
  • Create a production ready Dockerfile
  • Allow to inject SECRET_KEY, RDB_URL and deployment type through env
4 years ago

rebased onto 77dc002

4 years ago

rebased onto 0a9534f

4 years ago

rebased onto 2683f6e

4 years ago

changes have been made, @mprahl :palm_tree:

The dnf -y clean all needs to happen here too, otherwise this layer of the container image will always contain the DNF cache.

This isn't the right spot for it.

It's customary to make environment variables all caps

rebased onto 4556086

4 years ago

@mprahl ahh I see, ty for that. The dnf -y clean all has been moved!

:thumbsup:

Looks good to me!

@frantisekz could you please take a look as well?

:thumbsup:

Looks good to me!

@frantisekz could you please take a look as well?

Sure, seems okay from my side! Merging then.

Pull-Request has been merged by frantisekz

4 years ago