Spaces:
Build error
Build error
Update Dockerfile
Browse files8 unmodified lines910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091928 unmodified linesMAMBA_ROOT_PREFIX=/opt/micromamba \PYTHONUNBUFFERED=1 \PIP_NO_CACHE_DIR=1 \STREAMLIT_SERVER_PORT=7860 \STREAMLIT_SERVER_ADDRESS=0.0.0.0USER rootRUN apt-get update && apt-get install -y --no-install-recommends \ca-certificates curl bzip2 xz-utils gzip unzip zip git wget tini \build-essential procps libgomp1 libcurl4-openssl-dev libssl-dev \&& rm -rf /var/lib/apt/lists/*# Micromamba is used to isolate groups of bioinformatics tools whose Python# dependencies would otherwise conflict in one monolithic environment.RUN case "${TARGETARCH:-amd64}" in \amd64) MM_ARCH=64 ;; \arm64) MM_ARCH=aarch64 ;; \*) MM_ARCH=64 ;; \esac && \curl -fsSL "https://github.com/mamba-org/micromamba-releases/releases/download/${MICROMAMBA_VERSION}/micromamba-linux-${MM_ARCH}" \-o /usr/local/bin/micromamba && chmod +x /usr/local/bin/micromambaRUN micromamba config prepend channels conda-forge && \micromamba config append channels bioconda && \micromamba config set channel_priority flexible# Web application environment.RUN micromamba create -y -n app python=3.11 pip && micromamba clean --all --yes# --- Core WGS environment: read QC, assembly, polishing, distance/taxonomy, ---# --- alignment/tree tools. One or two packages per layer to bound memory. ---# --- First layer per env uses `create`; every later layer for the SAME env ---# --- must use `install`, since `create -n <existing name>` wipes and ---# --- recreates the environment instead of adding to it. ---RUN micromamba create -y -n core python=3.9 fastp fastqc && micromamba clean --all --yesRUN micromamba install -y -n core multiqc && micromamba clean --all --yesRUN micromamba install -y -n core spades && micromamba clean --all --yesRUN micromamba create -y -n quast python=3.10 quast && micromamba clean --all --yesRUN micromamba install -y -n core flye && micromamba clean --all --yesRUN micromamba install -y -n core unicycler && micromamba clean --all --yesRUN micromamba install -y -n core polypolish bwa samtools minimap2 && micromamba clean --all --yesRUN micromamba install -y -n core mash skani && micromamba clean --all --yesRUN micromamba install -y -n core mafft iqtree && micromamba clean --all --yesRUN micromamba install -y -n core blast minced && micromamba clean --all --yes# --- Surveillance / typing environment. No annotation-dependent tools. ---RUN micromamba create -y -n surveillance python=3.10 mlst && micromamba clean --all --yesRUN micromamba install -y -n surveillance snippy && micromamba clean --all --yesRUN micromamba install -y -n surveillance gubbins && micromamba clean --all --yes# --- Database-dependent tools, isolated and split one per layer. Reference ---# --- databases themselves are NOT baked into the image; mount under /data. ---RUN micromamba create -y -n taxonomy python=3.10 gtdbtk && micromamba clean --all --yesRUN micromamba create -y -n checkm2 -c conda-forge -c bioconda python=3.12 checkm2 && micromamba clean --all --yesRUN micromamba create -y -n functional python=3.10 genomad && micromamba clean --all --yesRUN micromamba install -y -n functional mob_suite && micromamba clean --all --yesRUN micromamba install -y -n functional integron_finder && micromamba clean --all --yesRUN micromamba create -y -n epidemiology python=3.10 chewbbaca && micromamba clean --all --yesRUN micromamba install -y -n epidemiology poppunk && micromamba clean --all --yesENV PATH=/opt/micromamba/envs/core/bin:/opt/micromamba/envs/quast/bin:/opt/micromamba/envs/surveillance/bin:/opt/micromamba/envs/taxonomy/bin:/opt/micromamba/envs/checkm2/bin:/opt/micromamba/envs/functional/bin:/opt/micromamba/envs/epidemiology/bin:/opt/micromamba/envs/app/bin:$PATH# Hugging Face Docker Spaces expect the runtime user to be UID 1000.# ubuntu:24.04 already ships a default user at UID 1000, so remove it first# rather than colliding with useradd.RUN existing_user="$(getent passwd 1000 | cut -d: -f1 || true)"; \if [ -n "$existing_user" ] && [ "$existing_user" != "appuser" ]; then \userdel -r "$existing_user" 2>/dev/null || userdel "$existing_user"; \fi && \useradd -m -u 1000 -s /bin/bash appuser && \mkdir -p /app /data /home/appuser/.streamlit /home/appuser/.cache && \chown -R 1000:1000 /app /data /home/appuserWORKDIR /appCOPY --chown=1000:1000 requirements.txt /app/requirements.txtRUN /opt/micromamba/envs/app/bin/python -m pip install --no-cache-dir -r /app/requirements.txtCOPY --chown=1000:1000 . /appENV HOME=/home/appuser XDG_CACHE_HOME=/home/appuser/.cacheUSER 1000EXPOSE 7860ENTRYPOINT ["/usr/bin/tini", "--"]CMD ["/opt/micromamba/envs/app/bin/streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]8 unmodified lines91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714728 unmodified linesMAMBA_ROOT_PREFIX=/opt/micromamba \PYTHONUNBUFFERED=1 \PIP_NO_CACHE_DIR=1 \PIP_DISABLE_PIP_VERSION_CHECK=1 \STREAMLIT_SERVER_PORT=7860 \STREAMLIT_SERVER_ADDRESS=0.0.0.0SHELL ["/bin/bash", "-o", "pipefail", "-c"]USER root# ============================================================# SYSTEM DEPENDENCIES# ============================================================RUN apt-get update && \apt-get install -y --no-install-recommends \ca-certificates \curl \wget \git \bzip2 \xz-utils \gzip \unzip \zip \tini \build-essential \procps \libgomp1 \libcurl4-openssl-dev \libssl-dev \libglib2.0-0 \libgl1 \&& rm -rf /var/lib/apt/lists/*# ============================================================# MICROMAMBA# ============================================================RUN case "${TARGETARCH:-amd64}" in \amd64) MM_ARCH=64 ;; \arm64) MM_ARCH=aarch64 ;; \*) MM_ARCH=64 ;; \esac && \curl -fsSL \"https://github.com/mamba-org/micromamba-releases/releases/download/${MICROMAMBA_VERSION}/micromamba-linux-${MM_ARCH}" \-o /usr/local/bin/micromamba && \chmod +x /usr/local/bin/micromamba && \micromamba --version# ============================================================# CONDA CHANNEL CONFIGURATION# ============================================================RUN micromamba config prepend channels conda-forge && \micromamba config append channels bioconda && \micromamba config set channel_priority strict# ============================================================# STREAMLIT APPLICATION ENVIRONMENT# ============================================================RUN micromamba create -y -n app \python=3.11 \pip && \micromamba clean --all --yes# ============================================================# CORE WGS ENVIRONMENT## Read QC# Assembly# Hybrid assembly# Polishing# Sequence manipulation# ANI / distance# Alignment# Phylogenetics# BLAST# CRISPR detection# ============================================================RUN micromamba create -y -n core \python=3.9 \fastp \fastqc && \micromamba clean --all --yes# MultiQCRUN micromamba install -y -n core \multiqc && \micromamba clean --all --yes# SPAdesRUN micromamba install -y -n core \spades && \micromamba clean --all --yes# FlyeRUN micromamba install -y -n core \flye && \micromamba clean --all --yes# UnicyclerRUN micromamba install -y -n core \unicycler && \micromamba clean --all --yes# Polishing and mappingRUN micromamba install -y -n core \polypolish \bwa \samtools \minimap2 && \micromamba clean --all --yes# Genome distance and ANIRUN micromamba install -y -n core \mash \skani && \micromamba clean --all --yes# Alignment and phylogeneticsRUN micromamba install -y -n core \mafft \iqtree && \micromamba clean --all --yes# BLAST and CRISPR detectionRUN micromamba install -y -n core \blast \minced && \micromamba clean --all --yes# ============================================================# QUAST ENVIRONMENT## Kept separate because QUAST pulls a large dependency tree.# ============================================================RUN micromamba create -y -n quast \python=3.10 \quast && \micromamba clean --all --yes# ============================================================# SURVEILLANCE / TYPING ENVIRONMENT# ============================================================RUN micromamba create -y -n surveillance \python=3.10 \mlst && \micromamba clean --all --yes# SNP analysisRUN micromamba install -y -n surveillance \snippy && \micromamba clean --all --yes# Recombination analysisRUN micromamba install -y -n surveillance \gubbins && \micromamba clean --all --yes# ============================================================# GTDB-TK TAXONOMY ENVIRONMENT## GTDB database is deliberately NOT included in the image.# Mount or download it separately under /data.# ============================================================RUN micromamba create -y -n taxonomy \python=3.10 \gtdbtk && \micromamba clean --all --yes# ============================================================# CHECKM2 ENVIRONMENT## IMPORTANT:# Current Bioconda CheckM2 1.1.0 metadata has an incompatible# Python / TensorFlow dependency combination.## Therefore:# 1. Create a compatible Python 3.12 environment manually.# 2. Install native dependencies with micromamba.# 3. Install TensorFlow 2.17 with pip.# 4. Install the official CheckM2 1.1.0 source from GitHub.## The large CheckM2 DIAMOND database is NOT included.# ============================================================RUN micromamba create -y -n checkm2 \-c conda-forge \-c bioconda \python=3.12 \pip \"numpy=1.26.4" \"scikit-learn=1.6.1" \pandas \scipy \lightgbm \requests \packaging \tqdm \"diamond=2.1.11" \"prodigal=2.6.3" && \micromamba clean --all --yes# TensorFlow required by CheckM2 1.1.0RUN /opt/micromamba/envs/checkm2/bin/python \-m pip install --no-cache-dir \"tensorflow==2.17.0"# Install official CheckM2 1.1.0 source.## --no-deps is intentional because the dependencies have already# been installed above, avoiding the broken current Bioconda# dependency specification.RUN /opt/micromamba/envs/checkm2/bin/python \-m pip install --no-cache-dir --no-deps \"git+https://github.com/chklovski/CheckM2.git@1.1.0"# Verify CheckM2 installationRUN /opt/micromamba/envs/checkm2/bin/checkm2 --help >/dev/null# ============================================================# GENOMAD ENVIRONMENT## Viral and plasmid identification.## Database is NOT baked into the Docker image.# ============================================================RUN micromamba create -y -n genomad \python=3.10 \genomad && \micromamba clean --all --yes# ============================================================# MOB-SUITE ENVIRONMENT## Plasmid reconstruction and typing.## Isolated from geNomad to avoid Python dependency conflicts.# ============================================================RUN micromamba create -y -n mobsuite \python=3.10 \mob_suite && \micromamba clean --all --yes# ============================================================# INTEGRON FINDER ENVIRONMENT# ============================================================RUN micromamba create -y -n integron \python=3.10 \integron_finder && \micromamba clean --all --yes# ============================================================# CHEWBBACA ENVIRONMENT## cgMLST / wgMLST analysis.# ============================================================RUN micromamba create -y -n chewbbaca \python=3.10 \chewbbaca && \micromamba clean --all --yes# ============================================================# POPPUNK ENVIRONMENT## Population structure analysis.## Kept separate from chewBBACA because both have substantial# and potentially conflicting Python dependencies.# ============================================================RUN micromamba create -y -n poppunk \python=3.10 \poppunk && \micromamba clean --all --yes# ============================================================# RUNTIME PATH## The Streamlit application's Python environment comes first.# Bioinformatics programs remain directly callable by name.# ============================================================ENV PATH=/opt/micromamba/envs/app/bin:\/opt/micromamba/envs/core/bin:\/opt/micromamba/envs/quast/bin:\/opt/micromamba/envs/surveillance/bin:\/opt/micromamba/envs/taxonomy/bin:\/opt/micromamba/envs/checkm2/bin:\/opt/micromamba/envs/genomad/bin:\/opt/micromamba/envs/mobsuite/bin:\/opt/micromamba/envs/integron/bin:\/opt/micromamba/envs/chewbbaca/bin:\/opt/micromamba/envs/poppunk/bin:\$PATH# ============================================================# HUGGING FACE USER## Hugging Face Docker Spaces normally run applications as# UID 1000.## ubuntu:24.04 normally already contains a UID 1000 account,# therefore remove it first to avoid useradd collision.# ============================================================RUN existing_user="$(getent passwd 1000 | cut -d: -f1 || true)" && \if [ -n "$existing_user" ] && [ "$existing_user" != "appuser" ]; then \userdel -r "$existing_user" 2>/dev/null || \userdel "$existing_user" || true; \fi && \if ! id appuser >/dev/null 2>&1; then \useradd -m -u 1000 -s /bin/bash appuser; \fi && \mkdir -p \/app \/data \/data/databases \/data/results \/data/uploads \/home/appuser/.streamlit \/home/appuser/.cache \/home/appuser/.cache/huggingface && \chown -R 1000:1000 \/app \/data \/home/appuser# ============================================================# APPLICATION# ============================================================WORKDIR /app# Copy requirements first to improve Docker layer caching.COPY --chown=1000:1000 requirements.txt /app/requirements.txt# Install web application dependencies only inside app env.RUN /opt/micromamba/envs/app/bin/python \-m pip install \--no-cache-dir \-r /app/requirements.txt# Copy application source.COPY --chown=1000:1000 . /app# ============================================================# RUNTIME ENVIRONMENT# ============================================================ENV HOME=/home/appuser \XDG_CACHE_HOME=/home/appuser/.cache \HF_HOME=/home/appuser/.cache/huggingface# ============================================================# BASIC INSTALLATION CHECK## These checks catch missing executables during Docker build# rather than after deployment.# ============================================================RUN command -v fastp && \command -v fastqc && \command -v multiqc && \command -v spades.py && \command -v flye && \command -v unicycler && \command -v bwa && \command -v samtools && \command -v minimap2 && \command -v mash && \command -v skani && \command -v mafft && \command -v blastn && \command -v minced && \command -v quast.py && \command -v mlst && \command -v snippy && \command -v gtdbtk && \command -v checkm2 && \command -v genomad && \command -v mob_recon && \command -v integron_finder# ============================================================# FINAL PERMISSIONS# ============================================================RUN chown -R 1000:1000 \/app \/data \/home/appuser# ============================================================# RUN AS NON-ROOT# ============================================================USER 1000# ============================================================# STREAMLIT# ============================================================EXPOSE 7860ENTRYPOINT ["/usr/bin/tini", "--"]CMD ["/opt/micromamba/envs/app/bin/streamlit","run","app.py","--server.address=0.0.0.0","--server.port=7860","--server.headless=true"]
Dockerfile+439-59