Containerization with Docker
https://hutchdatascience.org/Containers_for_Scientists/02-why-containers.html
Motivation:
I want to create my own custom docker built off the base image for RStudio for Terra.
I want this custom image to allow for GitHub Copilot to be enabled.
These steps assume that you have 1) already created a Docker account and 2) installed Docker on your local laptop
Step 1
# pull image to your local computer
docker pull \
us.gcr.io/broad-dsp-gcr-public/anvil-rstudio-bioconductor:3.21.0Step 2
Go to directory where want to keep Dockerfile
Create Dockerfile and save as Dockerfile
cat > Dockerfile << EOF
# STEP 1: Use the downloaded Terra RStudio Base Image
FROM us.gcr.io/broad-dsp-gcr-public/anvil-rstudio-bioconductor:3.21.0
LABEL maintainer="Your Name <[email protected]>"
WORKDIR /home/rstudio/tb4i_analysis
# STEP 2: Install Node.js (Essential Copilot Dependency)
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# STEP 3: Configure RStudio Server to Enable GitHub Copilot
RUN echo "copilot-enabled=1" >> /etc/rstudio/rsession.conf
EOFStep 3
# build docker image
# note: i have to specify --platform because my laptop has Apple Silocon Chip but need linux/amd64 because that is what Terra base image uses
docker build --platform linux/amd64 -t username/dockerimagename .Step 4
Use the image name and tag as a custom image in Terra.bio.
if you don’t want to build this custom image yourself, you can use my image:
https://hub.docker.com/r/mattkrantz/anvil-rstudio-bioconductor-tb4i/tags
mattkrantz/anvil-rstudio-bioconductor-tb4i:3.21.0
Docker = sets up a virtual computer (e.g. install software)
Then saves the resulting state of the virtual computer = “image”
Container = running instance of an image
An image can be transferred and executed on any machine that has Docker installed
Containers = lightweight
Start rapidly
Run with little overhead
Do no need much storage space
Containers achieve this by reusing large parts of the host operating system.
Software versions should be precisely documented to ensure full computational reproducibility.
Rocker Project
Docker images of pre-configured selected version of R from MRAN
rocker/verse = RStudio and tidyverse
liftR= way to automatically identify dependencies and automatically generate a Docker image