|
| 1 | +# syntax=docker/dockerfile:1.4 |
| 2 | +FROM python:3.12-slim AS base |
| 3 | + |
| 4 | +WORKDIR /app |
| 5 | +ENV PYTHONUNBUFFERED=1 |
| 6 | +ENV DEBIAN_FRONTEND=noninteractive |
| 7 | + |
| 8 | +RUN --mount=type=cache,target=/var/cache/apt \ |
| 9 | + apt-get update -qq && \ |
| 10 | + apt-get install -yq --no-install-recommends \ |
| 11 | + git \ |
| 12 | + openssh-client \ |
| 13 | + wget \ |
| 14 | + gpg \ |
| 15 | + software-properties-common \ |
| 16 | + build-essential && \ |
| 17 | + apt-get clean && rm -rf /var/lib/apt/lists/* |
| 18 | + |
| 19 | +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \ |
| 20 | + chmod +x ~/miniconda.sh && \ |
| 21 | + bash ~/miniconda.sh -b -p /app/miniconda && \ |
| 22 | + rm ~/miniconda.sh && \ |
| 23 | + /app/miniconda/bin/conda init bash |
| 24 | + |
| 25 | +# Set environment variables to point to conda environment |
| 26 | +ENV VIRTUAL_ENV="/app/miniconda/bin" |
| 27 | +ENV PATH="/app/miniconda/bin:$PATH" |
| 28 | +ENV PYTHONPATH="/app/miniconda/lib/python3.12/site-packages:${PYTHONPATH:-}" |
| 29 | + |
| 30 | +# Install uv & mamba |
| 31 | +RUN pip3 install --no-cache-dir uv==0.5.21 |
| 32 | +RUN conda install -c conda-forge mamba -y |
| 33 | + |
| 34 | + |
| 35 | +# Install R and kernels in the crow_env environment |
| 36 | +RUN mamba install -c conda-forge -y \ |
| 37 | + r-base=4.3.3 \ |
| 38 | + r-recommended=4.3 \ |
| 39 | + r-irkernel=1.3.2 \ |
| 40 | + r-factominer=2.11 \ |
| 41 | + r-rcolorbrewer=1.1_3 \ |
| 42 | + r-devtools=2.4.5 \ |
| 43 | + r-broom=1.0.7 \ |
| 44 | + r-data.table=1.15.4 \ |
| 45 | + r-enrichr=3.2 \ |
| 46 | + r-factoextra=1.0.7 \ |
| 47 | + r-ggnewscale=0.5.0 \ |
| 48 | + r-ggrepel=0.9.6 \ |
| 49 | + r-ggpubr=0.6.0 \ |
| 50 | + r-ggvenn=0.1.10 \ |
| 51 | + r-janitor=2.2.1 \ |
| 52 | + r-multcomp=1.4_26 \ |
| 53 | + r-matrix=1.6_5 \ |
| 54 | + r-pheatmap=1.0.12 \ |
| 55 | + r-tidyverse=2.0.0 \ |
| 56 | + r-readxl=1.4.3 \ |
| 57 | + r-reshape=0.8.9 \ |
| 58 | + r-rstatix=0.7.2 \ |
| 59 | + r-viridis=0.6.5 \ |
| 60 | + udocker=1.3.17 \ |
| 61 | + imbalanced-learn=0.13.0 \ |
| 62 | + ipykernel=6.29.5 \ |
| 63 | + sqlite=3.47.2 \ |
| 64 | + anndata=0.11.1 \ |
| 65 | + biopython=1.84 \ |
| 66 | + datasets \ |
| 67 | + ete3=3.1.3 \ |
| 68 | + keras=3.7.0 \ |
| 69 | + jupyter=1.0.0 \ |
| 70 | + matplotlib=3.10.0 \ |
| 71 | + matplotlib-venn=1.1.1 \ |
| 72 | + nbconvert=7.16.4 \ |
| 73 | + numpy=2.0.2 \ |
| 74 | + optuna=4.1.0 \ |
| 75 | + openpyxl=3.1.5 \ |
| 76 | + pandas=2.2.3 \ |
| 77 | + plotly=5.24.1 \ |
| 78 | + rpy2=3.5.11 \ |
| 79 | + scipy=1.14.1 \ |
| 80 | + scanpy=1.10.4 \ |
| 81 | + seaborn=0.13.2 \ |
| 82 | + scikit-learn=1.6.0 \ |
| 83 | + statsmodels=0.14.4 \ |
| 84 | + umap-learn=0.5.7 |
| 85 | + |
| 86 | +RUN python -m ipykernel install --user --name python3 --display-name "Python 3 (ipykernel)" |
| 87 | +RUN R -e 'IRkernel::installspec(name = "R", displayname = "R (4.3.3)")' |
| 88 | + |
| 89 | +RUN mamba install -c conda-forge -c bioconda -y \ |
| 90 | + biokit=0.5.0 \ |
| 91 | + gseapy=1.1.4 \ |
| 92 | + blast=2.16.0 \ |
| 93 | + clipkit=2.3.0 \ |
| 94 | + fastqc=0.12.1 \ |
| 95 | + iqtree=2.3.6 \ |
| 96 | + mafft=7.526 \ |
| 97 | + metaeuk=7.bba0d80 \ |
| 98 | + mygene=3.2.2 \ |
| 99 | + perl=5.32.1 \ |
| 100 | + phykit=2.0.1 \ |
| 101 | + pydeseq2=0.4.12 \ |
| 102 | + spades=4.0.0 \ |
| 103 | + trim-galore=0.6.10 \ |
| 104 | + bioconductor-enhancedvolcano=1.20.0 \ |
| 105 | + bioconductor-deseq2=1.42.0 \ |
| 106 | + bioconductor-clusterprofiler=4.10.0 \ |
| 107 | + bioconductor-org.hs.eg.db=3.18.0 \ |
| 108 | + bioconductor-genomicranges=1.54.1 \ |
| 109 | + bioconductor-summarizedexperiment=1.32.0 \ |
| 110 | + bioconductor-apeglm=1.24.0 |
| 111 | + |
| 112 | +ENV UV_COMPILE_BYTECODE=1 |
| 113 | +ENV UV_LINK_MODE=copy |
| 114 | + |
| 115 | +FROM base AS builder |
| 116 | + |
| 117 | +ARG MODULE_NAME |
| 118 | +ARG USE_INTERNAL_DEPS |
| 119 | +ARG USE_GIT_CROW_CLIENT |
| 120 | + |
| 121 | + |
| 122 | +RUN mkdir -p ~/.ssh && \ |
| 123 | + chmod 700 ~/.ssh && \ |
| 124 | + ssh-keyscan github.com >> ~/.ssh/known_hosts && \ |
| 125 | + printf "Host github.com\n IdentityFile /root/.ssh/pqa_id_ed25519\n IdentityFile /root/.ssh/aviary_id_ed25519\nHost gitlab.company.com\n IdentityFile /root/.ssh/pqa_id_ed25519\n" > ~/.ssh/config |
| 126 | + |
| 127 | +RUN --mount=type=cache,target=/var/cache/apt \ |
| 128 | + apt-get update -qq && \ |
| 129 | + apt-get install -yq --no-install-recommends \ |
| 130 | + build-essential && \ |
| 131 | + apt-get clean && rm -rf /var/lib/apt/lists/* |
| 132 | + |
| 133 | +ENV VIRTUAL_ENV="/app/miniconda/bin" |
| 134 | +ENV PATH="/app/miniconda/bin:$PATH" |
| 135 | + |
| 136 | +COPY ./${MODULE_NAME} /app/${MODULE_NAME} |
| 137 | + |
| 138 | +RUN mkdir -p /app/scripts |
| 139 | +COPY ./scripts/run_crow_job.py /app/scripts/ |
| 140 | + |
| 141 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 142 | + --mount=type=ssh \ |
| 143 | + --mount=type=secret,id=ssh_key,target=/root/.ssh/aviary_id_ed25519.tmp \ |
| 144 | + if [ "$USE_INTERNAL_DEPS" = "true" ]; then \ |
| 145 | + cp /root/.ssh/aviary_id_ed25519.tmp /root/.ssh/aviary_id_ed25519 && \ |
| 146 | + chmod 400 /root/.ssh/aviary_id_ed25519 && \ |
| 147 | + git clone git@github.com:Future-House/aviary-internal.git /app/aviary_internal && \ |
| 148 | + cd /app/aviary_internal/aviary_internal && \ |
| 149 | + uv pip install --system -e .; \ |
| 150 | + else \ |
| 151 | + echo 'Skipping aviary_internal install'; \ |
| 152 | + fi && \ |
| 153 | + if [ "$USE_GIT_CROW_CLIENT" = "true" ]; then \ |
| 154 | + git clone git@github.com:Future-House/crow-ecosystem.git /app/crow-ecosystem && \ |
| 155 | + cd /app/crow-ecosystem/packages/crow-client && \ |
| 156 | + uv pip install --system -e .; \ |
| 157 | + else \ |
| 158 | + uv pip install --system crow-client; \ |
| 159 | + fi |
| 160 | + |
| 161 | +WORKDIR /app/${MODULE_NAME} |
| 162 | +RUN --mount=type=ssh \ |
| 163 | + --mount=type=secret,id=pqa_ssh_key,target=/root/.ssh/pqa_id_ed25519.tmp \ |
| 164 | + cp /root/.ssh/pqa_id_ed25519.tmp /root/.ssh/pqa_id_ed25519 && \ |
| 165 | + chmod 400 /root/.ssh/pqa_id_ed25519 && \ |
| 166 | + if [ -f "pyproject.toml" ]; then \ |
| 167 | + uv pip install --system -e .; \ |
| 168 | + elif [ -f "requirements.txt" ]; then \ |
| 169 | + uv pip install --system -r requirements.txt; \ |
| 170 | + else \ |
| 171 | + echo "No pyproject.toml or requirements.txt found" && exit 1; \ |
| 172 | + fi |
| 173 | + |
| 174 | +RUN find /app -type l -delete && \ |
| 175 | + rm -rf /app/.git |
| 176 | + |
| 177 | +FROM base AS runtime |
| 178 | + |
| 179 | +COPY --from=builder /app/ /app/ |
| 180 | + |
| 181 | +ENV VIRTUAL_ENV="/app/miniconda/bin" |
| 182 | +ENV PATH="/app/miniconda/bin:$PATH" |
| 183 | +ENV PYTHONPATH="/app/miniconda/lib/python3.12/site-packages:${PYTHONPATH:-}" |
| 184 | +CMD ["python", "scripts/run_crow_job.py"] |
0 commit comments