From 89aaaa53edcd347433e853bab87fedf198255d87 Mon Sep 17 00:00:00 2001 From: FrantiĊĦek Zatloukal Date: Feb 27 2020 12:59:19 +0000 Subject: Dockerfile --- diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..43ea95b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +# This will produce an image to be used in Openshift +# Build should be triggered from repo root like: +# podman build -f Dockerfile --tag +# Don't forget to mount persistent volume for development +# podman run --volume hostdir:/bbugs -ti -u 0 -p 5001:5001 + +# On OpenShift, edit Deployment Configs, add: +# spec: +# volumes: +# - name: run-volume +# emptyDir: {} +# containers: +# volumeMounts: +# - name: run-volume +# mountPath: /run + +FROM fedora:latest +LABEL \ + name="BlockerBugs application" \ + vendor="Fedora QE" \ + license="GPLv2+" \ + description="Web front end to the currently proposed blocker and freeze exception bugs for Fedora releases under development." \ + usage="" \ + build-date="" + +USER root +COPY ./blockerbugs.spec /opt/app-root/src/blockerbugs/blockerbugs.spec + +# install dependencies defined in RPM spec file +RUN dnf -y install findutils rpm-build python3-pip python3-mod_wsgi python3-pycurl \ + && rpm --query --requires --specfile /opt/app-root/src/blockerbugs/blockerbugs.spec | xargs -d '\n' dnf -y install + +COPY . /opt/app-root/src/blockerbugs/ +# install using --no-deps option to ensure nothing comes from PyPi +RUN pip3 install --no-deps /opt/app-root/src/blockerbugs/ + +# fix apache config for container use +RUN sed -i 's#^WSGISocketPrefix .*#WSGISocketPrefix /var/run/wsgi#' /opt/app-root/src/blockerbugs/conf/blockerbugs.conf + +# install launch script +RUN install -p -m 0755 /opt/app-root/src/blockerbugs/container_start.sh /usr/bin/container_start + +# config files +RUN install -d /usr/share/blockerbugs/conf \ + && install -p -m 0644 /opt/app-root/src/blockerbugs/conf/blockerbugs.conf /usr/share/blockerbugs/conf/ \ + && install -p -m 0644 /opt/app-root/src/blockerbugs/conf/blockerbugs.wsgi /usr/share/blockerbugs/ \ + && install -d /etc/blockerbugs \ + && install -p -m 0644 /opt/app-root/src/blockerbugs/conf/blockerbugs.conf /etc/httpd/conf.d/ + +# alembic +RUN install -p -m 0644 /opt/app-root/src/blockerbugs/alembic.ini /usr/share/blockerbugs/alembic.ini +RUN cp -a /opt/app-root/src/blockerbugs/alembic /usr/share/blockerbugs/alembic +RUN chmod -R 0755 /usr/share/blockerbugs/alembic + +# clean up +RUN rm -rf /opt/app-root/src/blockerbugs \ + && dnf -y autoremove findutils rpm-build \ + && dnf clean all + +# EXPOSE 5001/tcp +EXPOSE 5001 + +# Persistent VOLUME +VOLUME [ "/bbugs" ] + +CMD [ "runserver" ] +ENTRYPOINT [ "/usr/bin/container_start" ] +USER 1001:0 \ No newline at end of file diff --git a/container_start.sh b/container_start.sh new file mode 100755 index 0000000..bd9d9cb --- /dev/null +++ b/container_start.sh @@ -0,0 +1,9 @@ +#!/usr/bin/bash +if [[ $1 == runserver ]]; then + blockerbugs init_db + mod_wsgi-express-3 start-server /usr/share/blockerbugs/blockerbugs.wsgi --user apache --group apache \ + --port 5001 --threads 5 --include-file /etc/httpd/conf.d/blockerbugs.conf --log-level info \ + --log-to-terminal --access-log --startup-log +else + blockerbugs "$@" +fi \ No newline at end of file