Skip to content

Commit

Permalink
updated base image
Browse files Browse the repository at this point in the history
  • Loading branch information
popenc committed Apr 8, 2024
1 parent 4720fbf commit e0a500a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 21 deletions.
57 changes: 37 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
# Builds an image for CTS calculator celery worker

ARG version=dev

FROM python:3.10.12-slim
FROM mambaorg/micromamba:1.5.8-alpine3.19

ENV APP_USER=www-data
ENV CONDA_ENV="pyenv"

RUN apt-get update && \
apt-get install -y build-essential
USER root

COPY . /src/
RUN adduser -S $APP_USER -G $APP_USER

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

COPY . /src/
WORKDIR /src

RUN pip install -r requirements.txt
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

ENV PYTHONPATH /src:$PYTHONPATH
ENV PATH /src:$PATH

# Removes any trace of pip to resolve an open CVE.
# TODO: Generalize this using "find" (see hms).
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
# # 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 chown -R $APP_USER:$APP_USER /src

USER $APP_USER
ENV DJANGO_SETTINGS_MODULE "settings"
EXPOSE 8080

ENV PYTHONPATH /src:$PYTHONPATH
ENV PATH /src:$PATH

USER $APP_USER
2 changes: 1 addition & 1 deletion cts_calcs
13 changes: 13 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions start-manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
micromamba run -n pyenv celery -A tasks worker -Q manager_queue -l info -n manager_worker -c 1
2 changes: 2 additions & 0 deletions start-worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
micromamba run -n pyenv celery -A tasks worker -Q cts_queue -l info -n cts_worker -c 1

0 comments on commit e0a500a

Please sign in to comment.