Skip to content

Commit

Permalink
Merge pull request #548 from jashapiro/jashapiro/542-update-hello-r-d…
Browse files Browse the repository at this point in the history
…ocker

Set Renv not to activate in docker images
  • Loading branch information
jashapiro committed Jun 27, 2024
2 parents e1ce548 + db7185e commit f0a863d
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 9 deletions.
5 changes: 4 additions & 1 deletion analyses/cell-type-ewings/.Rprofile
Original file line number Diff line number Diff line change
@@ -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')
}
13 changes: 8 additions & 5 deletions analyses/cell-type-ewings/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion analyses/doublet-detection/.Rprofile
Original file line number Diff line number Diff line change
@@ -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')
}
3 changes: 3 additions & 0 deletions analyses/doublet-detection/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
5 changes: 4 additions & 1 deletion analyses/hello-R/.Rprofile
Original file line number Diff line number Diff line change
@@ -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')
}
10 changes: 10 additions & 0 deletions analyses/hello-R/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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')"

Expand Down
3 changes: 3 additions & 0 deletions analyses/hello-python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion analyses/simulate-sce/.Rprofile
Original file line number Diff line number Diff line change
@@ -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')
}
3 changes: 3 additions & 0 deletions analyses/simulate-sce/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'))"

Expand Down
9 changes: 9 additions & 0 deletions create-analysis-module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions templates/analysis-module/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f0a863d

Please sign in to comment.