diff --git a/analyses/cell-type-ewings/.Rprofile b/analyses/cell-type-ewings/.Rprofile index 81b960f5c..45301dbc7 100644 --- a/analyses/cell-type-ewings/.Rprofile +++ b/analyses/cell-type-ewings/.Rprofile @@ -1 +1,4 @@ -source("renv/activate.R") +# Don't activate renv in an OpenScPCA docker image +if(Sys.getenv('OPENSCPCA_DOCKER') != 'TRUE'){ + source('renv/activate.R') +} diff --git a/analyses/cell-type-ewings/Dockerfile b/analyses/cell-type-ewings/Dockerfile index 45984ce7e..2c2da3e2e 100644 --- a/analyses/cell-type-ewings/Dockerfile +++ b/analyses/cell-type-ewings/Dockerfile @@ -8,6 +8,9 @@ LABEL org.opencontainers.image.description="Docker image for the OpenScPCA analy LABEL org.opencontainers.image.authors="OpenScPCA scpca@ccdatalab.org" LABEL org.opencontainers.image.source="https://github.com/AlexsLemonade/OpenScPCA-analysis/tree/main/analyses/cell-type-ewings" +# Set an environment variable to allow checking if we are in an OpenScPCA container +ENV OPENSCPCA_DOCKER TRUE + # Disable the renv cache to install packages directly into the R library ENV RENV_CONFIG_CACHE_ENABLED FALSE # set a name for the conda environment @@ -18,11 +21,11 @@ ENV PATH="/opt/conda/bin:${PATH}" # Install dependencies for renv library RUN apt-get -y update && \ - DEBIAN_FRONTEND=noninteractive \ - apt-get install --no-install-recommends -y \ - pandoc \ - wget \ - && rm -rf /var/lib/apt/lists/* + DEBIAN_FRONTEND=noninteractive \ + apt-get install --no-install-recommends -y \ + pandoc \ + wget \ + && rm -rf /var/lib/apt/lists/* # Install miniconda # adapted from https://github.com/ContinuumIO/docker-images/blob/main/miniconda3/debian/Dockerfile diff --git a/analyses/doublet-detection/.Rprofile b/analyses/doublet-detection/.Rprofile index 81b960f5c..45301dbc7 100644 --- a/analyses/doublet-detection/.Rprofile +++ b/analyses/doublet-detection/.Rprofile @@ -1 +1,4 @@ -source("renv/activate.R") +# Don't activate renv in an OpenScPCA docker image +if(Sys.getenv('OPENSCPCA_DOCKER') != 'TRUE'){ + source('renv/activate.R') +} diff --git a/analyses/doublet-detection/Dockerfile b/analyses/doublet-detection/Dockerfile index f2e70db0c..8a8f8b1f6 100644 --- a/analyses/doublet-detection/Dockerfile +++ b/analyses/doublet-detection/Dockerfile @@ -8,6 +8,9 @@ LABEL org.opencontainers.image.source="https://github.com/AlexsLemonade/OpenScPC # set a name for the conda environment 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 ENV PATH="/opt/conda/bin:${PATH}" diff --git a/analyses/hello-R/.Rprofile b/analyses/hello-R/.Rprofile index 81b960f5c..45301dbc7 100644 --- a/analyses/hello-R/.Rprofile +++ b/analyses/hello-R/.Rprofile @@ -1 +1,4 @@ -source("renv/activate.R") +# Don't activate renv in an OpenScPCA docker image +if(Sys.getenv('OPENSCPCA_DOCKER') != 'TRUE'){ + source('renv/activate.R') +} diff --git a/analyses/hello-R/Dockerfile b/analyses/hello-R/Dockerfile index 890479dc0..4bbd899f6 100644 --- a/analyses/hello-R/Dockerfile +++ b/analyses/hello-R/Dockerfile @@ -6,6 +6,16 @@ FROM bioconductor/r-ver:3.19 LABEL org.opencontainers.image.authors="OpenScPCA scpca@ccdatalab.org" LABEL org.opencontainers.image.source="https://github.com/AlexsLemonade/OpenScPCA-analysis/tree/main/analyses/hello-R" +# Set an environment variable to allow checking if we are in an OpenScPCA container +ENV OPENSCPCA_DOCKER TRUE + +# Install additional system dependencies +RUN apt-get -y update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get install --no-install-recommends -y \ + pandoc \ + && rm -rf /var/lib/apt/lists/* + # Install renv to enable later package installation RUN Rscript -e "install.packages('renv')" diff --git a/analyses/hello-python/Dockerfile b/analyses/hello-python/Dockerfile index e18401320..ceee7189d 100644 --- a/analyses/hello-python/Dockerfile +++ b/analyses/hello-python/Dockerfile @@ -6,6 +6,9 @@ FROM continuumio/miniconda3:24.1.2-0 LABEL org.opencontainers.image.authors="OpenScPCA scpca@ccdatalab.org" LABEL org.opencontainers.image.source="https://github.com/AlexsLemonade/OpenScPCA-analysis/tree/main/analyses/hello-python" +# Set an environment variable to allow checking if we are in an OpenScPCA container +ENV OPENSCPCA_DOCKER TRUE + # set a name for the conda environment ARG ENV_NAME=openscpca-hello-python diff --git a/analyses/simulate-sce/.Rprofile b/analyses/simulate-sce/.Rprofile index 81b960f5c..45301dbc7 100644 --- a/analyses/simulate-sce/.Rprofile +++ b/analyses/simulate-sce/.Rprofile @@ -1 +1,4 @@ -source("renv/activate.R") +# Don't activate renv in an OpenScPCA docker image +if(Sys.getenv('OPENSCPCA_DOCKER') != 'TRUE'){ + source('renv/activate.R') +} diff --git a/analyses/simulate-sce/Dockerfile b/analyses/simulate-sce/Dockerfile index a2f7b1839..4d4d92714 100644 --- a/analyses/simulate-sce/Dockerfile +++ b/analyses/simulate-sce/Dockerfile @@ -8,6 +8,9 @@ LABEL org.opencontainers.image.description="Docker image for the OpenScPCA analy LABEL org.opencontainers.image.authors="OpenScPCA scpca@ccdatalab.org" LABEL org.opencontainers.image.source="https://github.com/AlexsLemonade/OpenScPCA-analysis/tree/main/analyses/simulate-sce" +# Set an environment variable to allow checking if we are in an OpenScPCA container +ENV OPENSCPCA_DOCKER TRUE + ENV RENV_CONFIG_CACHE_ENABLED FALSE RUN Rscript -e "install.packages(c('remotes', 'renv'))" diff --git a/create-analysis-module.py b/create-analysis-module.py index 10727c48b..0e809550d 100755 --- a/create-analysis-module.py +++ b/create-analysis-module.py @@ -215,6 +215,15 @@ def main() -> None: ["Rscript", "-e", renv_script], cwd=module_dir, ) + + # Set .Rprofile to not activate renv in an OpenScPCA Docker image + (module_dir / ".Rprofile").write_text( + "# Don't activate renv in an OpenScPCA docker image\n" + "if (Sys.getenv('OPENSCPCA_DOCKER') != 'TRUE') {\n" + " source('renv/activate.R')\n" + "}\n" + ) + # make the components directory and add a dependencies.R file component_dir = module_dir / "components" component_dir.mkdir(exist_ok=True) diff --git a/templates/analysis-module/Dockerfile b/templates/analysis-module/Dockerfile index 6c7d6a95d..53dca29e2 100644 --- a/templates/analysis-module/Dockerfile +++ b/templates/analysis-module/Dockerfile @@ -5,3 +5,6 @@ FROM ubuntu:22.04 # For more information, see https://specs.opencontainers.org/image-spec/annotations/?v=v1.0.1 LABEL org.opencontainers.image.authors="OpenScPCA scpca@ccdatalab.org" LABEL org.opencontainers.image.source="https://github.com/AlexsLemonade/OpenScPCA-analysis/tree/main/templates/analysis-module" + +# Set an environment variable to allow checking if we are in an OpenScPCA container +ENV OPENSCPCA_DOCKER TRUE