From 1b600107a54d12d690c1cbedb838d4e18ec6eb5a Mon Sep 17 00:00:00 2001 From: "spaceBearAmadeus (Alex)" Date: Wed, 30 Oct 2024 12:53:08 -0400 Subject: [PATCH] updated base for conda env build and management rather than poetry --- Dockerfile-base | 109 ++++++---------- ...file-base_BIOSIMULATOR_PROCESSES(original) | 0 _Dockerfile-base_CURRENT_STABLE | 121 ++++++++++++++++++ assets/environment.base.yml | 12 ++ 4 files changed, 170 insertions(+), 72 deletions(-) rename _Dockerfile-base => _Dockerfile-base_BIOSIMULATOR_PROCESSES(original) (100%) create mode 100644 _Dockerfile-base_CURRENT_STABLE create mode 100644 assets/environment.base.yml diff --git a/Dockerfile-base b/Dockerfile-base index 2e7ecb0e4..194f6c8d9 100644 --- a/Dockerfile-base +++ b/Dockerfile-base @@ -1,18 +1,20 @@ # FROM ghcr.io/biosimulators/biosimulators:latest THE STABLE VERSION OF BIOSIMULATOR PROCESSES IMAGE IS 0.0.4 # FROM ghcr.io/vivarium-collective/biosimulator-processes:0.0.4 + FROM ubuntu:22.04 LABEL authors="alexanderpatrie" ENV DEBIAN_FRONTEND=noninteractive ENV MONGO_URI="mongodb://mongodb/?retryWrites=true&w=majority&appName=bio-check" +ENV PATH="/opt/miniconda/bin:$PATH" # handle app creds from google RUN mkdir /.google COPY ./assets/.biosimulations.json /.google/.bio-check.json -# COPY ./.bio-check.json /.google/.bio-check.json +# install os deps RUN apt-get update && apt-get install -y --no-install-recommends \ python3.10 \ ca-certificates \ @@ -33,89 +35,52 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ libatlas-base-dev \ swig \ - pkg-config \ - curl \ + pkg-config \ tar \ libgl1-mesa-glx \ libice6 \ libpython3.10 \ - libsm6 \ - wget - -# hdf5/amici env deps -RUN apt-get update && apt-get install -y libatlas-base-dev libhdf5-serial-dev swig libboost-all-dev gnupg - -# handle main content -WORKDIR /app - -RUN mkdir /app/data - -# copy assets -COPY ./assets/requirements.base.txt ./assets/scripts/remove_deps.sh ./assets/scripts/update_deps.sh ./assets/dropped.txt ./assets/scripts/install_deps.sh /app/assets/ -COPY pyproject.toml poetry.lock /app/ - -# Configure PySCeS from assets + libsm6 +# && rm -rf /var/lib/apt/lists/* + +# install os deps for miniconda and hdf5 +RUN apt-get update \ + && apt-get install -y libatlas-base-dev \ + libhdf5-serial-dev \ + swig \ + libboost-all-dev \ + gnupg \ + wget \ + bzip2 \ + curl \ + git \ + && wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh \ + && bash /tmp/miniconda.sh -b -p /opt/miniconda + +# copy assets into image +COPY ./assets/environment.base.yml /tmp/environment.yml +COPY ./model-examples/sbml-core/Elowitz-Nature-2000-Repressilator.omex /app/data/Elowitz-Nature-2000-Repressilator.omex +COPY ./model-examples/sbml-core/Elowitz-Nature-2000-Repressilator /app/data/Elowitz-Nature-2000-Repressilator COPY ./assets/.pys_usercfg.ini /Pysces/.pys_usercfg.ini COPY ./assets/.pys_usercfg.ini /root/Pysces/.pys_usercfg.ini -RUN mkdir -p /Pysces \ +RUN echo "BioCompose Server" > /app/README.md \ + && mkdir -p /Pysces \ && mkdir -p /Pysces/psc \ && mkdir -p /root/Pysces \ && mkdir -p /root/Pysces/psc \ - && chmod ugo+rw -R /Pysces + && chmod ugo+rw -R /Pysces \ -# copy example files TODO: optimize this. -COPY ./model-examples/sbml-core/Elowitz-Nature-2000-Repressilator.omex /app/data/Elowitz-Nature-2000-Repressilator.omex -COPY ./model-examples/sbml-core/Elowitz-Nature-2000-Repressilator /app/data/Elowitz-Nature-2000-Repressilator - -# create readme for poetry -RUN echo "BioCompose Server" > /app/README.md - -# install poetry and deps -RUN python3.10 -m pip install --upgrade pip \ - && python3.10 -m pip install poetry \ - && poetry config virtualenvs.in-project true \ - && poetry env use 3.10 \ - && poetry install --without=api,worker,pysces,masspy - - -# install smoldyn -# RUN . /app/.venv/bin/activate \ -# && wget https://www.smoldyn.org/smoldyn-2.73.tgz \ -# && tar -xzf smoldyn-2.73.tgz \ -# && cd smoldyn-2.73 \ -# && cd build \ -# && cmake .. -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3.10) \ -# && make \ -# && make install -# && rm -rf /var/lib/apt/lists/* \ -# && apt-get clean \ -# && apt-get autoclean +# set conda to use path and create env +RUN conda env create -f /tmp/environment.yml -# RUN . /app/.venv/bin/activate \ -# && curl -O https://download.opensuse.org/repositories/home:/dilawar/xUbuntu_22.04/amd64/smoldyn_2.64.4-1+2.1_amd64.deb \ -# && dpkg -i smoldyn_2.64.4-1+2.1_amd64.deb +# ensure conda env shell is active +SHELL ["/bin/bash", "-c"] -# RUN . /app/.venv/bin/activate \ -# && echo 'deb http://download.opensuse.org/repositories/home:/dilawar/xUbuntu_22.04/ /' | tee /etc/apt/sources.list.d/home:dilawar.list \ -# && curl -fsSL https://download.opensuse.org/repositories/home:dilawar/xUbuntu_22.04/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/home_dilawar.gpg > /dev/null \ -# && apt update \ -# && apt install smoldyn +# test command with conda +RUN /opt/miniconda/envs/my-env/bin/python --version -# fix python version constraint, lock env, and check compatible -# RUN sed -i 's/python = ">=3.10"/python = "^3.10"/' /app/pyproject.toml \ -# && poetry lock \ -# && poetry check - -# TODO: fix this eventually, but for now (10/2024) biosimulators-processes is not used -# RUN rm -r biosimulator_processes - -# remove existing cobra installation TODO: clean this up -# RUN poetry remove cobra && poetry remove zarr - -# install project deps (shared) -# RUN chmod +x /app/assets/install_deps.sh \ -# && /app/assets/install_deps.sh /app/assets/requirements.base.txt +# create app space +WORKDIR /app +RUN mkdir /app/data -# TODO: create shared tooling module which is a set of the sum of api and worker data_model.py & shared.py -# COPY ./assets/shared.py /app/shared.py diff --git a/_Dockerfile-base b/_Dockerfile-base_BIOSIMULATOR_PROCESSES(original) similarity index 100% rename from _Dockerfile-base rename to _Dockerfile-base_BIOSIMULATOR_PROCESSES(original) diff --git a/_Dockerfile-base_CURRENT_STABLE b/_Dockerfile-base_CURRENT_STABLE new file mode 100644 index 000000000..2e7ecb0e4 --- /dev/null +++ b/_Dockerfile-base_CURRENT_STABLE @@ -0,0 +1,121 @@ +# FROM ghcr.io/biosimulators/biosimulators:latest THE STABLE VERSION OF BIOSIMULATOR PROCESSES IMAGE IS 0.0.4 +# FROM ghcr.io/vivarium-collective/biosimulator-processes:0.0.4 + +FROM ubuntu:22.04 + +LABEL authors="alexanderpatrie" + +ENV DEBIAN_FRONTEND=noninteractive +ENV MONGO_URI="mongodb://mongodb/?retryWrites=true&w=majority&appName=bio-check" + +# handle app creds from google +RUN mkdir /.google +COPY ./assets/.biosimulations.json /.google/.bio-check.json +# COPY ./.bio-check.json /.google/.bio-check.json + +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3.10 \ + ca-certificates \ + libhdf5-dev \ + libhdf5-serial-dev \ + python3-pip \ + python3-dev \ + build-essential \ + libncurses5 \ + libxml2 \ + cmake \ + make \ + libx11-dev \ + libc6-dev \ + libx11-6 \ + libgl1-mesa-dev \ + libc6 \ + gcc \ + libatlas-base-dev \ + swig \ + pkg-config \ + curl \ + tar \ + libgl1-mesa-glx \ + libice6 \ + libpython3.10 \ + libsm6 \ + wget + +# hdf5/amici env deps +RUN apt-get update && apt-get install -y libatlas-base-dev libhdf5-serial-dev swig libboost-all-dev gnupg + +# handle main content +WORKDIR /app + +RUN mkdir /app/data + +# copy assets +COPY ./assets/requirements.base.txt ./assets/scripts/remove_deps.sh ./assets/scripts/update_deps.sh ./assets/dropped.txt ./assets/scripts/install_deps.sh /app/assets/ +COPY pyproject.toml poetry.lock /app/ + +# Configure PySCeS from assets +COPY ./assets/.pys_usercfg.ini /Pysces/.pys_usercfg.ini +COPY ./assets/.pys_usercfg.ini /root/Pysces/.pys_usercfg.ini +RUN mkdir -p /Pysces \ + && mkdir -p /Pysces/psc \ + && mkdir -p /root/Pysces \ + && mkdir -p /root/Pysces/psc \ + && chmod ugo+rw -R /Pysces + +# copy example files TODO: optimize this. +COPY ./model-examples/sbml-core/Elowitz-Nature-2000-Repressilator.omex /app/data/Elowitz-Nature-2000-Repressilator.omex +COPY ./model-examples/sbml-core/Elowitz-Nature-2000-Repressilator /app/data/Elowitz-Nature-2000-Repressilator + +# create readme for poetry +RUN echo "BioCompose Server" > /app/README.md + +# install poetry and deps +RUN python3.10 -m pip install --upgrade pip \ + && python3.10 -m pip install poetry \ + && poetry config virtualenvs.in-project true \ + && poetry env use 3.10 \ + && poetry install --without=api,worker,pysces,masspy + + +# install smoldyn +# RUN . /app/.venv/bin/activate \ +# && wget https://www.smoldyn.org/smoldyn-2.73.tgz \ +# && tar -xzf smoldyn-2.73.tgz \ +# && cd smoldyn-2.73 \ +# && cd build \ +# && cmake .. -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=$(which python3.10) \ +# && make \ +# && make install +# && rm -rf /var/lib/apt/lists/* \ +# && apt-get clean \ +# && apt-get autoclean + +# RUN . /app/.venv/bin/activate \ +# && curl -O https://download.opensuse.org/repositories/home:/dilawar/xUbuntu_22.04/amd64/smoldyn_2.64.4-1+2.1_amd64.deb \ +# && dpkg -i smoldyn_2.64.4-1+2.1_amd64.deb + +# RUN . /app/.venv/bin/activate \ +# && echo 'deb http://download.opensuse.org/repositories/home:/dilawar/xUbuntu_22.04/ /' | tee /etc/apt/sources.list.d/home:dilawar.list \ +# && curl -fsSL https://download.opensuse.org/repositories/home:dilawar/xUbuntu_22.04/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/home_dilawar.gpg > /dev/null \ +# && apt update \ +# && apt install smoldyn + +# fix python version constraint, lock env, and check compatible +# RUN sed -i 's/python = ">=3.10"/python = "^3.10"/' /app/pyproject.toml \ +# && poetry lock \ +# && poetry check + +# TODO: fix this eventually, but for now (10/2024) biosimulators-processes is not used +# RUN rm -r biosimulator_processes + +# remove existing cobra installation TODO: clean this up +# RUN poetry remove cobra && poetry remove zarr + +# install project deps (shared) +# RUN chmod +x /app/assets/install_deps.sh \ +# && /app/assets/install_deps.sh /app/assets/requirements.base.txt + + +# TODO: create shared tooling module which is a set of the sum of api and worker data_model.py & shared.py +# COPY ./assets/shared.py /app/shared.py diff --git a/assets/environment.base.yml b/assets/environment.base.yml new file mode 100644 index 000000000..b7470cd5b --- /dev/null +++ b/assets/environment.base.yml @@ -0,0 +1,12 @@ +name: base +channels: + - defaults + - conda-forge +dependencies: + - python=3.8 + - numpy + - flask + - pip + - pip: + - requests + - some-other-pip-package