diff --git a/Dockerfile b/Dockerfile index 9f798888a..f42e5b95f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,20 @@ -FROM fedora:26 +FROM redhat/ubi8 -RUN dnf -y groupinstall "Development tools" \ - && dnf -y install python-devel python-tools python3-devel python3-tools sshpass which supervisor procps\ - && dnf clean all \ - && rm -rf /var/cache/dnf +RUN dnf -yq install python39 make openssh-clients glibc-langpack-en &&\ + dnf clean all &&\ + python3 -m venv /opt/venv -RUN pip install --no-cache-dir virtualenv -RUN virtualenv -p python3 ~/venv -# Create base directory -RUN mkdir -p /app +ENV PATH="/opt/venv/bin:${PATH}" -# Setup dependencies -COPY requirements.txt /app/requirements.txt -RUN . ~/venv/bin/activate; pip install -r /app/requirements.txt gunicorn==20.0.4 +RUN pip install --upgrade pip + +WORKDIR /app +COPY requirements.txt . +RUN pip install -r requirements.txt # Create /etc/ssl/qpc RUN mkdir -p /etc/ssl/qpc/ -VOLUME /etc/ssl/qpc/ -COPY deploy/ssl/server.crt /etc/ssl/qpc/ -COPY deploy/ssl/server.csr /etc/ssl/qpc/ -COPY deploy/ssl/server.key /etc/ssl/qpc/ - +COPY deploy/ssl/* /etc/ssl/qpc/ # Create /deploy RUN mkdir -p /deploy @@ -29,17 +23,10 @@ COPY deploy/docker_run.sh /deploy COPY deploy/server_run.sh /deploy COPY deploy/setup_user.py /deploy -# Config supervisor -COPY deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf - # Create log directories RUN mkdir -p /var/log/supervisor/ VOLUME /var/log -# Create /sshkeys -RUN mkdir -p /sshkeys -VOLUME /sshkeys - # Create /var/data RUN mkdir -p /var/data VOLUME /var/data @@ -50,9 +37,7 @@ COPY quipucords/scanner/network/runner/roles/ /etc/ansible/roles/ VOLUME /etc/ansible/roles/ # Copy server code -COPY . /app/ -WORKDIR /app -VOLUME /app +COPY . . # Set production environment ARG BUILD_COMMIT=master @@ -68,10 +53,10 @@ ENV DJANGO_LOG_FILE=/var/log/app.log ENV QUIPUCORDS_LOGGING_LEVEL=INFO ENV LC_ALL=en_US.UTF-8 ENV LANG=en_US.UTF-8 -ENV PYTHONHASHSEED=0 +ENV PYTHONPATH=/app/quipucords # Initialize database & Collect static files -RUN . ~/venv/bin/activate;make server-static +RUN make server-static RUN ls -lta /var/data WORKDIR /var/log diff --git a/deploy/docker_run.sh b/deploy/docker_run.sh index c9a08a67c..cb78111cf 100755 --- a/deploy/docker_run.sh +++ b/deploy/docker_run.sh @@ -1,10 +1,4 @@ #!/usr/bin/env bash eval `ssh-agent -s` -if [[ ${USE_SUPERVISORD,,} = "false" ]]; then - echo "Running without supervisord" - /deploy/server_run.sh >& /var/log/quipucords.log -else - echo "Running with supervisord" - /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf -fi +/deploy/server_run.sh 2>&1 | tee /var/log/quipucords.log diff --git a/deploy/server_run.sh b/deploy/server_run.sh index e4d941ee4..69eb4ebc3 100755 --- a/deploy/server_run.sh +++ b/deploy/server_run.sh @@ -1,11 +1,5 @@ #!/usr/bin/env bash -source ~/venv/bin/activate - make server-migrate server-set-superuser -C /app -if [[ ${USE_SUPERVISORD,,} = "false" ]]; then - cd /app/quipucords -fi - -~/venv/bin/gunicorn quipucords.wsgi -c /deploy/gunicorn.conf.py +gunicorn quipucords.wsgi -c /deploy/gunicorn.conf.py diff --git a/requirements.txt b/requirements.txt index 89efc1222..9a6634a26 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,5 @@ PyYAML==5.4 requests==2.25.1 whitenoise==5.2.0 psycopg2-binary==2.8.6 -ansible-runner==1.4.6 \ No newline at end of file +ansible-runner==1.4.6 +gunicorn==20.0.4 \ No newline at end of file