11# Full performance multi-stage build with complete CUDA toolchain
2- FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 AS builder
2+ ARG CUDA_BASE_IMAGE_TAG=12.2.2-cudnn8-devel-ubuntu22.04
3+ FROM nvidia/cuda:${CUDA_BASE_IMAGE_TAG} AS builder
34
45# Install complete build dependencies including CUDA compiler tools
56RUN apt-get update && apt-get install -y \
@@ -13,29 +14,35 @@ RUN apt-get update && apt-get install -y \
1314 && rm -rf /var/lib/apt/lists/*
1415
1516# Install miniforge
17+ # FIXME this needs to be pinned, with more recent versions (25.11.0-1) the package resolution is stuck
1618RUN wget -P /tmp \
1719 "https://github.com/conda-forge/miniforge/releases/download/25.3.1-0/Miniforge3-Linux-x86_64.sh" \
1820 && bash /tmp/Miniforge3-Linux-x86_64.sh -b -p /opt/conda \
1921 && rm /tmp/Miniforge3-Linux-x86_64.sh
2022
2123ENV PATH=/opt/conda/bin:$PATH
24+ ENV CONDA_PREFIX=/opt/conda
2225
2326# Copy and install dependencies with aggressive cleanup
2427COPY environments/production.yml /opt/openfold3/environment.yml
2528RUN mamba env update -n base --file /opt/openfold3/environment.yml \
2629 && mamba clean --all --yes \
2730 && conda clean --all --yes
2831
29- # Copy the entire source tree
30- COPY . /opt/openfold3/
32+ # Copy the minimal set of files needed to install the package
33+ COPY setup.py /opt/openfold3/
34+ COPY pyproject.toml /opt/openfold3/
35+ COPY openfold3/__init__.py /opt/openfold3/openfold3/
36+ COPY scripts/ /opt/openfold3/scripts/
3137
3238# Install third party dependencies
3339WORKDIR /opt/
3440RUN /opt/openfold3/scripts/install_third_party_dependencies.sh
3541
3642# Install the package
3743WORKDIR /opt/openfold3
38- RUN python3 setup.py install
44+ # even `pip install --no-build-isolation` not actually working here, needs investigation
45+ RUN python setup.py install
3946
4047# Set CUDA architecture for compilation (adjust based on your GPU)
4148ENV TORCH_CUDA_ARCH_LIST="8.0;8.6;9.0"
@@ -44,10 +51,11 @@ ENV TORCH_CUDA_ARCH_LIST="8.0;8.6;9.0"
4451# RUN python3 -c "import deepspeed; deepspeed.ops.op_builder.EvoformerAttnBuilder().load()" || \
4552# python3 -c "import deepspeed; print('DeepSpeed ops loaded successfully')"
4653
47- # Runtime stage - use devel image for full CUDA support
48- FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 AS runtime
54+ # Devel stage - use devel image for full CUDA support
55+ ARG CUDA_BASE_IMAGE_TAG=12.2.2-cudnn8-devel-ubuntu22.04
56+ FROM nvidia/cuda:${CUDA_BASE_IMAGE_TAG} AS devel
4957
50- # Install runtime dependencies
58+ # Install devel dependencies
5159RUN apt-get update && apt-get install -y \
5260 libopenmpi3 \
5361 libaio1 \
@@ -85,7 +93,16 @@ ENV KMP_AFFINITY=none
8593ENV LIBRARY_PATH=/opt/conda/lib:$LIBRARY_PATH
8694ENV LD_LIBRARY_PATH=/opt/conda/lib:$LD_LIBRARY_PATH
8795
88- # Copy the entire source tree to the runtime image
89- COPY --from=builder /opt/openfold3 /opt/openfold3
96+ # Copy the entire source tree directly (at the very end for optimal caching)
97+ COPY . /opt/openfold3
9098
9199WORKDIR /opt/openfold3
100+
101+ # Test stage - build on devel layer with test dependencies
102+ FROM devel AS test
103+
104+ COPY environments/requirements-test.txt /opt/openfold3/requirements-test.txt
105+
106+ WORKDIR /opt/openfold3
107+ RUN pip install -r requirements-test.txt
108+ RUN pip install --no-deps --editable .
0 commit comments