Skip to content

Commit 97efb02

Browse files
committed
feat: binder
1 parent 6b4963b commit 97efb02

File tree

4 files changed

+207
-1
lines changed

4 files changed

+207
-1
lines changed

.binder/.dockerignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Local development
2+
docker/
3+
4+
# Git and GitHub
5+
.git/
6+
.github/
7+
8+
# Generated outputs
9+
*. pdf
10+
docs/
11+
_site/
12+
13+
# Quarto cache
14+
.quarto/
15+
_freeze/
16+
17+
# renv cache (will be recreated in container)
18+
renv/library/
19+
renv/local/
20+
renv/cellar/
21+
renv/sandbox/
22+
renv/python/
23+
renv/staging/
24+
25+
# R temporary files
26+
.Rhistory
27+
. RData
28+
.Rproj. user/
29+
30+
# Python
31+
__pycache__/
32+
*.pyc
33+
. venv/
34+
.pytest_cache/
35+
36+
# OS files
37+
.DS_Store
38+
Thumbs.db
39+

.binder/Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This file defines how to build a custom Docker image
2+
# based on the rocker/binder image for MyBinder.org compatibility.
3+
# Unlike the docker/Dockerfile (for local development with RStudio),
4+
# this image is designed for ephemeral, read-only reproducibility checks.
5+
6+
# --- Base Image ---
7+
# Use the official rocker/binder version 4.4.2 as the starting point.
8+
# This image includes R, RStudio Server, Quarto, Pandoc, and JupyterHub
9+
# pre-installed, and is specifically designed for MyBinder.org.
10+
FROM rocker/binder:4.4.2
11+
12+
# --- Image Metadata ---
13+
# Add labels to the image for identification and documentation purposes.
14+
# These are useful metadata but do not affect the container's functionality.
15+
LABEL maintainer="Pablo Rogers <[email protected]>" \
16+
description="MyBinder environment for ARTE"
17+
18+
# --- renv Configuration ---
19+
# Set environment variables to configure where renv stores its cache
20+
# and the installed package library.
21+
# These paths are used to ensure renv functions correctly inside the container.
22+
ENV RENV_PATHS_CACHE=/home/rstudio/renv/cache
23+
# Path for the global renv cache (stores . tar.gz of downloaded packages).
24+
ENV RENV_PATHS_LIBRARY=/home/rstudio/renv/library
25+
# Path for the R package library installed by renv for this project.
26+
27+
# --- Copy renv Configuration Files ---
28+
# Copy necessary renv files from the build context (your local system)
29+
# to the home directory inside the container.
30+
# These files are essential for renv to function correctly.
31+
COPY --chown=rstudio renv.lock /home/rstudio/renv.lock
32+
# The lock file defining the exact versions of R packages.
33+
COPY --chown=rstudio .Rprofile /home/rstudio/.Rprofile
34+
# The profile file that activates renv when R starts.
35+
COPY --chown=rstudio renv/activate.R /home/rstudio/renv/activate.R
36+
# The renv activation script.
37+
38+
# --- Copy Project Files ---
39+
# Copy the entire project to the container's home directory.
40+
# This includes all source files, data, and documentation.
41+
COPY --chown=rstudio . /home/rstudio
42+
43+
# --- Restore R Packages via renv ---
44+
# Run the R command to restore R packages listed in renv.lock.
45+
# This installs the packages at the versions specified into the directory
46+
# defined by RENV_PATHS_LIBRARY.
47+
# The -s flag makes the R execution quieter.
48+
RUN R -s -e "renv::restore()"
49+
50+
# --- Install TinyTeX via Quarto ---
51+
# Install TinyTeX using Quarto's built-in installer.
52+
# This provides a lightweight LaTeX distribution (~150MB) that is
53+
# compatible with current CTAN repositories and automatically installs
54+
# missing LaTeX packages during PDF rendering.
55+
# Note: rocker/binder comes with TeX Live, but it may have version
56+
# incompatibilities with remote repositories. TinyTeX from Quarto
57+
# ensures a consistent and up-to-date LaTeX environment.
58+
RUN quarto install tinytex
59+
60+
# Note: Unlike docker/Dockerfile, this image does not require
61+
# explicit port exposure or CMD instructions, as rocker/binder
62+
# already configures JupyterHub and RStudio Server for MyBinder.org.
63+
# This environment is ephemeral (max ~12h) and non-persistent,
64+
# intended only for reproducibility verification, not active development.

.binder/README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Binder Configuration
2+
3+
This folder contains the configuration files needed to run ARTE on [MyBinder.org](https://mybinder.org/), a free cloud service that creates executable environments from GitHub repositories.
4+
5+
## Purpose
6+
7+
Unlike the `docker/` folder (designed for local development with persistent storage), the `.binder/` configuration creates an **ephemeral environment** for reproducibility verification. This allows anyone to:
8+
9+
- Verify that the ARTE environment is fully reproducible
10+
- Explore the project structure and outputs without local setup
11+
- Test the Quarto rendering process in a clean environment
12+
13+
> **Note:** MyBinder sessions are temporary (maximum ~12 hours) and non-persistent. Any changes made will be lost when the session ends. This environment is intended for verification and exploration, not active development.
14+
15+
## Launching ARTE on MyBinder
16+
17+
Click the badge below to launch ARTE in your browser:
18+
19+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/phdpablo/article-template/main)
20+
21+
### Step-by-Step Instructions
22+
23+
#### 1. Wait for the Environment to Build
24+
25+
After clicking the badge, MyBinder will build the Docker image and start your session. **Please be patient** — the first build can take **10-15 minutes** as it needs to:
26+
27+
- Download the base image
28+
- Restore all R packages from `renv.lock`
29+
- Install TinyTeX for PDF rendering
30+
31+
#### 2. Open RStudio from JupyterHub
32+
33+
Once the environment loads, you will see **JupyterHub** in your browser. To access RStudio:
34+
35+
- Look for the **RStudio** button/icon in the JupyterHub launcher
36+
- Click it to open RStudio in a **new browser tab**
37+
38+
#### 3. Open the Project in RStudio
39+
40+
When RStudio opens:
41+
42+
- The ARTE project should already be loaded
43+
- If not, go to `File > Open Project... ` and select the `.Rproj` file
44+
45+
#### 4. Render the Project with Quarto
46+
47+
Open the **Terminal** tab in RStudio (next to Console) and run:
48+
49+
```bash
50+
quarto render
51+
```
52+
53+
This will render all Quarto documents and generate the outputs in the `docs/` folder. The rendering process may take a few minutes.
54+
55+
#### 5. View the Rendered ARTE
56+
57+
After rendering completes:
58+
59+
1. Navigate to the `docs/` folder in the RStudio Files pane
60+
2. Click on `index.html`
61+
3. Select **"View in Web Browser"** to open it in a new browser tab
62+
4. Navigate through the ARTE to explore all sections and outputs
63+
64+
## Files in This Folder
65+
66+
| File | Description |
67+
|------|-------------|
68+
| `Dockerfile` | Defines the Docker image based on `rocker/binder:4.4.2` with renv packages and TinyTeX |
69+
70+
## Differences from docker/Dockerfile
71+
72+
| Aspect | docker/Dockerfile | .binder/Dockerfile |
73+
|--------|-------------------|-------------------|
74+
| **Base image** | `rocker/verse:4.5.1` | `rocker/binder:4.4.2` |
75+
| **Purpose** | Local development | Reproducibility verification |
76+
| **Persistence** | Volumes for data persistence | Ephemeral (no persistence) |
77+
| **LaTeX** | TeX Live (pre-installed) | TinyTeX (via Quarto) |
78+
| **Interface** | RStudio Server only | JupyterHub + RStudio |
79+
| **Duration** | Unlimited | Max ~12 hours |
80+
81+
## Troubleshooting
82+
83+
### Build is taking too long
84+
85+
The build takes longer because MyBinder needs to create the image from scratch.
86+
87+
### Session timed out
88+
89+
MyBinder sessions expire after ~10-20 minutes of inactivity or ~12 hours maximum. Simply relaunch by clicking the badge again.
90+
91+
### PDF rendering fails
92+
93+
If `quarto render` fails for PDF output, try rendering only HTML:
94+
95+
```bash
96+
quarto render --to html
97+
```
98+
99+
## Learn More
100+
101+
- [MyBinder Documentation](https://mybinder.readthedocs.io/)
102+
- [Rocker Binder Images](https://rocker-project.org/images/versioned/binder.html)
103+
- [Quarto Documentation](https://quarto.org/)

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ This workflow file (`deploy.yml`) is already included in the template. To make i
3838
- Go to the **Actions** tab of your GitHub repository.
3939
- Click on **Deploy Quarto Website** in the left sidebar list of workflows.
4040
- Click the **Run workflow** button (usually a dropdown/dark blue button) and confirm.
41-
5. **View Your Website:** After the workflow runs successfully (you can see the status in the **Actions** tab), your website will be available at `https://your-username.github.io/your-repository-name/`. It might take a twelve or thirteen minute after the workflow completes for the site to update.
41+
5. **View Your Website:** After the workflow runs successfully (you can see the status in the **Actions** tab), your website will be available at `https://your-username.github.io/your-repository-name/`. It might take a two or three minutes after the workflow completes for the site to update.
4242

4343
This automation ensures that your published website is always up-to-date with the latest version of your `main` branch.

0 commit comments

Comments
 (0)