Skip to content

Commit

Permalink
Merge pull request #740 from jashapiro/711-713-docker-gha-miniforge
Browse files Browse the repository at this point in the history
Update docker images and GHA to use miniforge
  • Loading branch information
jashapiro authored Aug 30, 2024
2 parents 402371e + b87bdae commit 436026b
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .github/components/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ mesenchymal
metacell
metacells
Miniconda
Miniforge
misidentification
MSC
multifactor
Expand Down Expand Up @@ -154,11 +155,11 @@ scDblFinder
SCE
ScPCA
SCPCP
scRNA
scrublet
SEACells
SemVar
SingleR
scRNA
snRNA
socio
SSO
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run_hello-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:

- name: Set up conda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest

- name: Install and activate locked conda environment
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run_metacells.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:

- name: Set up conda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest

- name: Install and activate locked conda environment
run: |
Expand Down
28 changes: 15 additions & 13 deletions analyses/cell-type-ewings/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ENV RENV_CONFIG_CACHE_ENABLED=FALSE
# set a name for the conda environment
ARG ENV_NAME=openscpca-cell-type-ewings

# set environment variables to install miniconda
# set environment variables to install conda
ENV PATH="/opt/conda/bin:${PATH}"

# Install dependencies for renv library
Expand All @@ -27,18 +27,20 @@ RUN apt-get -y update && \
wget \
&& rm -rf /var/lib/apt/lists/*

# Install miniconda
# adapted from https://github.com/ContinuumIO/docker-images/blob/main/miniconda3/debian/Dockerfile
RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \
&& rm -f Miniconda3-latest-Linux-x86_64.sh \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete
# Install conda via miniforge
# adapted from https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile
RUN curl -L "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" -o /tmp/miniforge.sh \
&& bash /tmp/miniforge.sh -b -p /opt/conda \
&& rm -f /tmp/miniforge.sh \
&& conda clean --tarballs --index-cache --packages --yes \
&& find /opt/conda -follow -type f -name '*.a' -delete \
&& find /opt/conda -follow -type f -name '*.pyc' -delete \
&& conda clean --force-pkgs-dirs --all --yes \
&& echo ". /opt/conda/etc/profile.d/conda.sh && conda activate base" >> /etc/skel/.bashrc \
&& echo ". /opt/conda/etc/profile.d/conda.sh && conda activate base" >> ~/.bashrc

# add conda-lock
RUN conda install conda-lock
RUN conda install conda-lock && conda clean --all --yes

# Install renv to enable later package installation
RUN Rscript -e "install.packages('renv')"
Expand All @@ -47,8 +49,8 @@ RUN Rscript -e "install.packages('renv')"
COPY conda-lock.yml conda-lock.yml

# restore from conda-lock.yml file and clean up to reduce image size
RUN conda-lock install -n ${ENV_NAME} conda-lock.yml && \
conda clean --all --yes
RUN conda-lock install -n ${ENV_NAME} conda-lock.yml \
&& conda clean --all --yes

# Activate conda environment on bash launch
RUN echo "conda activate ${ENV_NAME}" >> ~/.bashrc
Expand Down
35 changes: 19 additions & 16 deletions analyses/doublet-detection/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ ARG ENV_NAME=openscpca-doublet-detection
# Set an environment variable to allow checking if we are in an OpenScPCA container
ENV OPENSCPCA_DOCKER=TRUE

# set environment variables to install miniconda
# set environment variables to install conda
ENV PATH="/opt/conda/bin:${PATH}"

# Install Miniconda
# adapted from https://github.com/ContinuumIO/docker-images/blob/main/miniconda3/debian/Dockerfile
RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \
&& rm -f Miniconda3-latest-Linux-x86_64.sh \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete
# Install conda via miniforge
# adapted from https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile
RUN curl -L "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" -o /tmp/miniforge.sh \
&& bash /tmp/miniforge.sh -b -p /opt/conda \
&& rm -f /tmp/miniforge.sh \
&& conda clean --tarballs --index-cache --packages --yes \
&& find /opt/conda -follow -type f -name '*.a' -delete \
&& find /opt/conda -follow -type f -name '*.pyc' -delete \
&& conda clean --force-pkgs-dirs --all --yes \
&& echo ". /opt/conda/etc/profile.d/conda.sh && conda activate base" >> /etc/skel/.bashrc \
&& echo ". /opt/conda/etc/profile.d/conda.sh && conda activate base" >> ~/.bashrc

# Install conda-lock
RUN conda install --channel=conda-forge --name=base conda-lock
RUN conda install --channel=conda-forge --name=base conda-lock \
&& conda clean --all --yes

# Install pandoc dependency
RUN apt-get -y update && \
Expand All @@ -44,8 +47,11 @@ ENV RENV_CONFIG_CACHE_ENABLED=FALSE
COPY conda-lock.yml conda-lock.yml

# restore from conda-lock.yml file and clean up to reduce image size
RUN conda-lock install -n ${ENV_NAME} conda-lock.yml && \
conda clean --all --yes
RUN conda-lock install -n ${ENV_NAME} conda-lock.yml \
&& conda clean --all --yes

# Activate conda environment on bash launch
RUN echo "conda activate ${ENV_NAME}" >> ~/.bashrc

# Copy the renv.lock file from the host environment to the image
COPY renv.lock renv.lock
Expand All @@ -65,8 +71,5 @@ RUN Rscript -e "proc <- basilisk::basiliskStart(env = zellkonverter::zellkonvert
basilisk::basiliskStop(proc); \
basilisk.utils::cleanConda()"

# Activate conda environment on bash launch
RUN echo "conda activate ${ENV_NAME}" >> ~/.bashrc

# Set CMD to bash to activate the environment when launching
CMD ["/bin/bash"]
31 changes: 17 additions & 14 deletions docs/ensuring-repro/docker/docker-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ CMD ["/bin/bash"]
If your analysis module requires both R and conda environments, you may have to do just a bit more work to set up the Dockerfile, as there is not a single base image that includes both R and conda environments.
<!-- Should we make one, maybe? -->
We recommend starting with an R-based image and then installing conda manually.
In the example below, we have adapted the installation steps used in the [official Miniconda Dockerfile](https://github.com/ContinuumIO/docker-images/blob/main/miniconda3/debian/Dockerfile).
In the example below, we have adapted the installation steps used in the [official Miniforge Dockerfile](https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile).

```Dockerfile
# Dockerfile for an analysis module with both R and conda environments
Expand All @@ -147,21 +147,24 @@ FROM bioconductor/r-ver:3.19
# set a name for the conda environment
ARG ENV_NAME=openscpca-analysis

# set environment variables to install miniconda
# set environment variables to install conda
ENV PATH="/opt/conda/bin:${PATH}"

# Install Miniconda
# adapted from https://github.com/ContinuumIO/docker-images/blob/main/miniconda3/debian/Dockerfile
RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc \
&& rm -f Miniconda3-latest-Linux-x86_64.sh \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete
# Install conda via miniforge
# adapted from https://github.com/conda-forge/miniforge-images/blob/master/ubuntu/Dockerfile
RUN curl -L "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" -o /tmp/miniforge.sh \
&& bash /tmp/miniforge.sh -b -p /opt/conda \
&& rm -f /tmp/miniforge.sh \
&& conda clean --tarballs --index-cache --packages --yes \
&& find /opt/conda -follow -type f -name '*.a' -delete \
&& find /opt/conda -follow -type f -name '*.pyc' -delete \
&& conda clean --force-pkgs-dirs --all --yes \
&& echo ". /opt/conda/etc/profile.d/conda.sh && conda activate base" >> /etc/skel/.bashrc \
&& echo ". /opt/conda/etc/profile.d/conda.sh && conda activate base" >> ~/.bashrc

# Install conda-lock
RUN conda install --channel=conda-forge --name=base conda-lock
RUN conda install --channel=conda-forge --name=base conda-lock \
&& conda clean --all --yes

# Install renv
RUN Rscript -e "install.packages('renv')"
Expand All @@ -173,8 +176,8 @@ ENV RENV_CONFIG_CACHE_ENABLED FALSE
COPY conda-lock.yml conda-lock.yml

# restore from conda-lock.yml file and clean up to reduce image size
RUN conda-lock install -n ${ENV_NAME} conda-lock.yml && \
conda clean --all --yes
RUN conda-lock install -n ${ENV_NAME} conda-lock.yml \
&& conda clean --all --yes

# Copy the renv.lock file from the host environment to the image
COPY renv.lock renv.lock
Expand Down
2 changes: 2 additions & 0 deletions templates/workflows/run_conda-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
- name: Set up conda
# Note that this creates and activates an environment named 'test' by default
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest

- name: Install and activate locked conda environment
run: |
Expand Down
2 changes: 2 additions & 0 deletions templates/workflows/run_conda-renv-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
- name: Set up conda
# Note that this creates and activates an environment named 'test' by default
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest

- name: Install conda-lock and activate locked conda environment
run: |
Expand Down

0 comments on commit 436026b

Please sign in to comment.