Skip to content

Commit

Permalink
updated base for conda env build and management rather than poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Oct 30, 2024
1 parent f631bb7 commit 1b60010
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 72 deletions.
109 changes: 37 additions & 72 deletions Dockerfile-base
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
File renamed without changes.
121 changes: 121 additions & 0 deletions _Dockerfile-base_CURRENT_STABLE
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions assets/environment.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: base
channels:
- defaults
- conda-forge
dependencies:
- python=3.8
- numpy
- flask
- pip
- pip:
- requests
- some-other-pip-package

0 comments on commit 1b60010

Please sign in to comment.