diff --git a/Dockerfile b/Dockerfile index 6e41aa8..1eadc8f 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,50 @@ # Builds an image for CTS calculator celery worker -ARG version=dev - -FROM python:3.9-alpine +FROM mambaorg/micromamba:1.5.8-alpine3.19 ENV APP_USER=www-data +ENV CONDA_ENV="pyenv" -COPY . /src/ +USER root -WORKDIR /src +RUN adduser -S $APP_USER -G $APP_USER -RUN pip install -r requirements.txt +RUN apk add --update --no-cache \ + build-base \ + jpeg-dev \ + zlib-dev \ + libjpeg \ + gettext \ + py3-lxml \ + py3-pillow \ + openldap-dev \ + python3-dev \ + linux-headers \ + && rm -rf /var/cache/apk/* -ENV PYTHONPATH /src:$PYTHONPATH -ENV PATH /src:$PATH +COPY . /src/ +WORKDIR /src -RUN apk update && \ - apk upgrade +RUN micromamba create -n $CONDA_ENV -c conda-forge python=3.10 +RUN micromamba install -n $CONDA_ENV -f /src/environment.yml +RUN micromamba clean -p -t -l --trash -y +RUN micromamba run -n $CONDA_ENV pip uninstall -y xhtml2pdf && micromamba run -n $CONDA_ENV pip install xhtml2pdf + +# # Removes any trace of pip to resolve an open CVE: +# RUN rm -rf \ +# /root/.cache/pip \ +# /usr/local/bin/pip \ +# /usr/local/bin/pip3.10 \ +# /usr/local/bin/pip3 \ +# /usr/local/lib/python3.10/site-packages/pip \ +# /usr/local/lib/python3.10/site-packages/pip-23.0.1.dist-info -RUN adduser -S $APP_USER -G $APP_USER RUN chown -R $APP_USER:$APP_USER /src +ENV DJANGO_SETTINGS_MODULE "settings" +EXPOSE 8080 + +ENV PYTHONPATH /src:$PYTHONPATH +ENV PATH /src:$PATH + USER $APP_USER diff --git a/cts_calcs b/cts_calcs index 85181a6..dc332b6 160000 --- a/cts_calcs +++ b/cts_calcs @@ -1 +1 @@ -Subproject commit 85181a6be957bfe272d2cb3c10a10fb455c16826 +Subproject commit dc332b66e99b19b9ea245a678cd637c95a9ea776 diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..505bf7c --- /dev/null +++ b/environment.yml @@ -0,0 +1,13 @@ +name: cts +channels: + - conda-forge + - defaults +dependencies: + - beautifulsoup4=4.12.3 + - celery=5.3.6 + - pymongo=4.6.3 + - python-dotenv=1.0.1 + - rdkit=2024.3.1 + - requests=2.31.0 + - pip: + - redis==5.0.3 diff --git a/requirements.txt b/requirements.txt index 19dbc42..866a335 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,6 @@ beautifulsoup4==4.10.0 celery==5.2.3 pymongo==4.0.2 python-dotenv==0.19.2 -redis==4.1.4 -requests==2.27.1 +rdkit==2023.3.1 +redis==4.4.4 +requests==2.31.0 diff --git a/start-manager.sh b/start-manager.sh new file mode 100644 index 0000000..7f34d1e --- /dev/null +++ b/start-manager.sh @@ -0,0 +1,2 @@ +#!/bin/bash +micromamba run -n pyenv celery -A tasks worker -Q manager_queue -l info -n manager_worker -c 1 \ No newline at end of file diff --git a/start-worker.sh b/start-worker.sh new file mode 100644 index 0000000..6a5bd07 --- /dev/null +++ b/start-worker.sh @@ -0,0 +1,2 @@ +#!/bin/bash +micromamba run -n pyenv celery -A tasks worker -Q cts_queue -l info -n cts_worker -c 1 \ No newline at end of file diff --git a/temp_config b/temp_config index c548aea..3f7299a 160000 --- a/temp_config +++ b/temp_config @@ -1 +1 @@ -Subproject commit c548aeac0a0b6e223e2b0588b4632a59b9168ece +Subproject commit 3f7299a79318f391260a67df5457921f92795dd1