Skip to content

Commit a06c99b

Browse files
committed
so it begins again ... 🌱
1 parent 6ea03ed commit a06c99b

File tree

6 files changed

+112
-59
lines changed

6 files changed

+112
-59
lines changed

.github/workflows/docker-image.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Binder Image
2+
on:
3+
workflow_dispatch: null
4+
push:
5+
paths:
6+
- Dockerfile
7+
- environment.yml
8+
- install.r
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions: write-all
13+
steps:
14+
- name: free extra disk space
15+
run: |
16+
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
17+
df -h
18+
- uses: actions/checkout@v3
19+
- name: Publish to GitHub Container Registry
20+
uses: elgohr/Publish-Docker-Github-Action@v5
21+
with:
22+
name: rocker-org/binder
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
registry: ghcr.io
26+
- name: Publish to Docker Registry
27+
uses: elgohr/Publish-Docker-Github-Action@v5
28+
with:
29+
name: rocker/binder
30+
username: ${{ secrets.DOCKER_USER }}
31+
password: ${{ secrets.DOCKER_TOKEN }}
32+

Dockerfile

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1-
FROM rocker/binder:4.2.0
1+
ARG BASE=quay.io/jupyter/minimal-notebook:ubuntu-24.04
2+
FROM $BASE
23

3-
## Declares build arguments
4-
ARG NB_USER
5-
ARG NB_UID
4+
# Make code-server extensions etc persist to container, not hub
5+
ENV XDG_DATA_HOME=/opt/share
66

7-
COPY --chown=${NB_USER} . ${HOME}
8-
9-
ENV DEBIAN_FRONTEND=noninteractive
107
USER root
11-
RUN echo "Checking for 'apt.txt'..." \
12-
; if test -f "apt.txt" ; then \
13-
apt-get update --fix-missing > /dev/null\
14-
&& xargs -a apt.txt apt-get install --yes \
15-
&& apt-get clean > /dev/null \
16-
&& rm -rf /var/lib/apt/lists/* \
17-
; fi
8+
# code-server (VSCode)
9+
RUN curl -fsSL https://code-server.dev/install.sh | sh && rm -rf .cache
10+
11+
# apt utilities, code-server setup
12+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/master/install_utilities.sh | bash
13+
14+
## Grant user sudoer privileges
15+
RUN adduser "$NB_USER" sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers
16+
17+
# Install R, RStudio
18+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/master/install_r.sh | bash
19+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/master/install_rstudio.sh | bash
20+
21+
## Add rstudio's binaries to path for quarto
22+
ENV PATH=$PATH:/usr/lib/rstudio-server/bin/quarto/bin
23+
1824
USER ${NB_USER}
1925

20-
## Run an install.R script, if it exists.
21-
RUN if [ -f install.R ]; then R --quiet -f install.R; fi
26+
# When run at build-time, install.r automagically handles any necessary apt-gets
27+
COPY install.r install.r
28+
RUN Rscript install.r
29+
30+
COPY vscode-extensions.txt vscode-extensions.txt
31+
RUN xargs -n 1 code-server --install-extension < vscode-extensions.txt
32+
33+
COPY environment.yml environment.yml
34+
RUN conda update --all --solver=classic -n base -c conda-forge conda && \
35+
conda env update --file environment.yml
36+

README.md

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,29 @@ Generate a Git repository that can run R code with RStudio on
66
the browser via [mybinder.org](https://mybinder.org) or any JupyterHub
77
from this template repository!
88

9-
Based on the [rocker/geospatial](https://hub.docker.com/r/rocker/geospatial)
10-
image.
11-
129
## How to use this repo
1310

14-
### 1. Create a new repo using this as a template
11+
### 1. Add a Dockerfile to your repo with contents like so:
12+
13+
```
14+
FROM rocker/binder
1515
16-
Use the [Use this template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template#creating-a-repository-from-a-template)
17-
button on GitHub. Use a descriptive name representing the
18-
GUI app you are running / demoing. You can then follow the rest of
19-
the instructions in this README from your newly created repository.
16+
COPY install.r install.r
17+
RUN Rscript install.r
18+
```
2019

2120
### 2. Install any packages you want
2221

23-
You can create an `install.R` file that will be executed on build.
24-
Use `install.packages` or `devtools::install_version`.
22+
You can create an `install.r` file that will be executed on build.
23+
Use `install.packages()` to install:
2524

2625
```R
2726
install.packages("ggplot2")
2827
```
2928

30-
Packages are installed from [packagemanager.rstudio.com](https://packagemanager.rstudio.com/client/#/),
31-
and binary packages are preferred wherever possible. For some R packages,
32-
you might need to install system packages via apt - you can do so by writing
33-
out a list of apt package names in `apt.txt`.
29+
Binary versions of packages will be quickly installed from [r2u](https://github.com/eddelbuettel/r2u) via [bspm](https://cloud.r-project.org/web/packages/bspm/index.html). _There is no need to manually manage 'system' dependencies with apt-get, these are handled automatically in the Docker build phase_.
30+
31+
Commonly used packages in the `tidyverse` and `geospatial` collection are already installed, see [`install.r`](install.r)
3432

3533
### 3. Modify the Binder Badge in the README.md
3634

@@ -39,30 +37,3 @@ You should modify it to point to your own repository. Keep the `urlpath=rstudio`
3937
parameter intact - that is what makes sure your repo will launch directly into
4038
RStudio
4139

42-
### 4. Add your R code and update README
43-
44-
Finally, add the R code you want to demo to the repository! Cleanup the README
45-
too so it talks about your code, not these instructions on setting up this repo
46-
47-
## Troubleshooting
48-
49-
**It didn't work! What do I do now?**. If you are installing additional R
50-
*packages, this will sometimes fail when a package requires an external library
51-
*that is not found on the container. We're working on a more elegant solution
52-
*for this case, but meanwhile, you'll need to modify the Dockerfile to install
53-
*these libraries. For instance, the `gsl` [R package page
54-
*reads](https://packagemanager.rstudio.com/client/#/repos/1/packages/gsl)
55-
56-
```shell
57-
# Install System Prerequisites for Ubuntu 20.04 (focal)
58-
apt-get install -y libgsl0-dev
59-
```
60-
61-
To solve this, you will need to add the following line to your `apt.txt` file:
62-
63-
```txt
64-
libgsl0-dev
65-
```
66-
67-
Or, just get in touch by opening an issue. We'll try and resolve common cases so
68-
more things work out of the box.

apt.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

environment.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: base
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- gh-scoped-creds
6+
- glances
7+
- git-filter-repo
8+
- jupyterlab-myst
9+
- jupyter-resource-usage
10+
- jupyter-rsession-proxy
11+
- jupyter-vscode-proxy
12+
- jupyterlab-myst
13+
- mystmd
14+
- pypdf
15+
- pip
16+
- pip:
17+
- jupyter-keepalive
18+

install.R

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
install.packages("ggplot2")
1+
# tidyverse/dev set
2+
install.packages(c(
3+
'languageserver',
4+
'httpgd',
5+
'quarto',
6+
'tidyverse',
7+
'devtools',
8+
'pak',
9+
'shiny',
10+
'duckdbfs',
11+
'arrow',
12+
'V8'))
13+
14+
install.packages("IRkernel")
15+
IRkernel::installspec(user = FALSE)
16+
17+
## Spatial set
18+
install.packages(c('sf', 'stars', 'gdalcubes', 'terra', 'tmap', 'mapgl'))
19+

0 commit comments

Comments
 (0)