Skip to content

Commit

Permalink
Merge pull request #206 from nmfs-opensci/eeholmes-patch-1
Browse files Browse the repository at this point in the history
add a pull version of R
  • Loading branch information
eeholmes authored Nov 24, 2024
2 parents cc7d7c3 + a7f4314 commit 39faa8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ USER root
ENV REPO_DIR="/srv/repo" \
DISPLAY=":1.0" \
R_VERSION="4.4.1"
# The latest rocker will set CRAN to 'latest' but we need a date stamped version for reproducibility
# So pull the latest and use one earlier
ARG R_VERSION_PULL="4.4.2"

# Add NB_USER to staff group (required for rocker script)
# Ensure the staff group exists first
Expand All @@ -35,7 +38,7 @@ RUN mkdir -p /pyrocket_scripts && \
RUN /pyrocket_scripts/install-conda-packages.sh ${REPO_DIR}/environment.yml

# Install R, RStudio via Rocker scripts. Requires the prefix for a rocker Dockerfile
RUN /pyrocket_scripts/install-rocker.sh "verse_${R_VERSION}"
RUN R_VERSION_PULL=$R_VERSION_PULL /pyrocket_scripts/install-rocker.sh "verse_${R_VERSION}"

# Install extra apt packages
# Install linux packages after R installation since the R install scripts get rid of packages
Expand Down
16 changes: 9 additions & 7 deletions scripts/install-rocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

# Check if a filename argument is provided
if [ -z "$1" ]; then
echo "Error: install-rocker.sh requires a rocker Dockerfile prefix. Will looke like verse.4.1.1. Exiting." >&2
echo "Error: install-rocker.sh requires a rocker Dockerfile prefix. Will look like verse.4.1.1. Exiting." >&2
echo "Usage: RUN /pyrocket_scripts/install-conda-packages.sh <filename>" >&2
exit 1
fi
Expand All @@ -34,15 +34,17 @@ R_DOCKERFILE="$1"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Copy in the rocker files. Work in ${REPO_DIR} to make sure I don't clobber anything
# R_VERSION_PULL may be different than R_VERSION. Specifically pulling latest but using R_VERSION prior to latest
# So that CRAN repo is pinned to a date.
cd ${REPO_DIR}
ROCKER_DOCKERFILE_NAME="${R_DOCKERFILE}.Dockerfile"
# For degugging use: wget https://github.com/eeholmes/rocker-versioned2/archive/refs/tags/R4.4.1.tar.gz
wget https://github.com/rocker-org/rocker-versioned2/archive/refs/tags/R${R_VERSION}.tar.gz
tar zxvf R${R_VERSION}.tar.gz && \
mv rocker-versioned2-R${R_VERSION}/scripts /rocker_scripts && \
mv rocker-versioned2-R${R_VERSION}/dockerfiles/${ROCKER_DOCKERFILE_NAME} /rocker_scripts/original.Dockerfile && \
rm R${R_VERSION}.tar.gz && \
rm -rf rocker-versioned2-R${R_VERSION}
wget https://github.com/rocker-org/rocker-versioned2/archive/refs/tags/R${R_VERSION_PULL}.tar.gz
tar zxvf R${R_VERSION_PULL}.tar.gz && \
mv rocker-versioned2-R${R_VERSION_PULL}/scripts /rocker_scripts && \
mv rocker-versioned2-R${R_VERSION_PULL}/dockerfiles/${ROCKER_DOCKERFILE_NAME} /rocker_scripts/original.Dockerfile && \
rm R${R_VERSION_PULL}.tar.gz && \
rm -rf rocker-versioned2-R${R_VERSION_PULL}

cd /
# Read the Dockerfile and process each line
Expand Down

0 comments on commit 39faa8b

Please sign in to comment.