Skip to content

Commit

Permalink
Merge pull request #207 from nmfs-opensci/test
Browse files Browse the repository at this point in the history
Fix problem with CRAN set to "latest"
  • Loading branch information
eeholmes authored Nov 25, 2024
2 parents 5249e36 + f8ed0a3 commit e851493
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ on:
branches: test
paths:
- '.github/workflows/test-build.yaml'
- 'Desktop/**'
- 'apt.txt'
- 'user-dirs.dirs'
- 'vscode-extensions.txt'
- 'environment.yml'
- 'start'
- 'postBuild'
- 'Dockerfile'
- 'custom_jupyter_server_config.json'
- 'scripts/**'
- '!book/**' # Ignore all changes in the /book directory
- '!docs/**' # Ignore all changes in the /docs directory
- '!base-image/**'
- '!README.md'
- '!conda-lock.yml'
- '!LICENSE'

jobs:
build:
runs-on: ubuntu-latest
Expand Down
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM ghcr.io/nmfs-opensci/py-rocket-base/base-image:latest

LABEL org.opencontainers.image.maintainers="[email protected]"
LABEL org.opencontainers.image.author="[email protected]"
LABEL org.opencontainers.image.source=https://github.com/nmfs-opensci/py-rocket-base
LABEL org.opencontainers.image.description="Geospatial Python (3.12), R (4.4) and Desktop"
LABEL org.opencontainers.image.description="Python (3.12), R (4.4.1), Desktop and Publishing tools"
LABEL org.opencontainers.image.licenses=Apache2.0
LABEL org.opencontainers.image.version=2024.11.19
LABEL org.opencontainers.image.version=2024.11.22

USER root

Expand All @@ -13,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 @@ -34,7 +38,10 @@ 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 Zotero; must be run before apt since zotero apt install requires this is run first
RUN wget -qO- https://raw.githubusercontent.com/retorquere/zotero-deb/master/install.sh | bash

# Install extra apt packages
# Install linux packages after R installation since the R install scripts get rid of packages
Expand All @@ -43,9 +50,6 @@ RUN /pyrocket_scripts/install-apt-packages.sh ${REPO_DIR}/apt.txt
# Install some basic VS Code extensions
RUN /pyrocket_scripts/install-vscode-extensions.sh ${REPO_DIR}/vscode-extensions.txt

# Install Zotero
RUN wget -qO- https://raw.githubusercontent.com/retorquere/zotero-deb/master/install.sh | bash

# Re-enable man pages disabled in Ubuntu 18 minimal image
# https://wiki.ubuntu.com/Minimal
RUN yes | unminimize
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 e851493

Please sign in to comment.