From d0af458693bceb0cb4d1f544b1814e8207aed3ff Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 17 Dec 2024 18:27:21 +0300 Subject: [PATCH] Use base ubi9 image --- Dockerfile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0a64e04..1df245c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,22 +44,29 @@ WORKDIR /backend/ COPY --from=builder /backend ./ COPY --from=builder /venv /venv COPY --from=builder /usr/share/nltk_data /usr/share/nltk_data/ + +ENV VIRTUAL_ENV="/venv" +# uWSGI configuration (customize as needed): +ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" PYTHONPATH=/backend \ + FLASK_APP=app/main.py UWSGI_WSGI_FILE=app/main.py UWSGI_SOCKET=:3031 UWSGI_HTTP=:5001 \ + UWSGI_VIRTUALENV=${VIRTUAL_ENV} UWSGI_MASTER=1 UWSGI_WORKERS=4 UWSGI_THREADS=8 UWSGI_MAX_FD=10000 \ + UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy PYTHONDONTWRITEBYTECODE=1 + RUN dnf -y upgrade && dnf -y install python3.11 python3.11-pip ca-certificates pcre-devel \ && dnf clean all \ - && pip install --upgrade pip \ - && pip install --upgrade setuptools \ - && mkdir -p -m 0700 /backend/storage \ && groupadd uwsgi && useradd -g uwsgi uwsgi \ - && chown -R uwsgi: /usr/share/nltk_data \ - && chown -R uwsgi: /backend + && chown -R uwsgi:uwsgi ${VIRTUAL_ENV} \ + && chown -R uwsgi:uwsgi /usr/share/nltk_data \ + && chown -R uwsgi:uwsgi /backend + USER uwsgi EXPOSE 5001 -ENV VIRTUAL_ENV="/venv" -# uWSGI configuration (customize as needed): -ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" PYTHONPATH=/backend \ - FLASK_APP=app/main.py UWSGI_WSGI_FILE=app/main.py UWSGI_SOCKET=:3031 UWSGI_HTTP=:5001 \ - UWSGI_VIRTUALENV=${VIRTUAL_ENV} UWSGI_MASTER=1 UWSGI_WORKERS=4 UWSGI_THREADS=8 UWSGI_MAX_FD=10000 UWSGI_LAZY_APPS=1 \ - UWSGI_WSGI_ENV_BEHAVIOR=holy PYTHONDONTWRITEBYTECODE=1 + +RUN mkdir -p -m 0644 /backend/storage \ + && source "${VIRTUAL_ENV}/bin/activate" \ + && pip install --upgrade pip \ + && pip install --upgrade setuptools + # Start uWSGI CMD ["/venv/bin/uwsgi", "--http-auto-chunked", "--http-keepalive"] HEALTHCHECK --interval=1m --timeout=5s --retries=2 CMD ["curl", "-s", "-f", "--show-error", "http://localhost:5001/"]