Skip to content

Commit 60c9651

Browse files
Merge pull request #29 from virtualstaticvoid/feat/build-multiple-r-versions
Add support for building multiple r versions
2 parents 39933ac + 5129611 commit 60c9651

File tree

8 files changed

+45
-32
lines changed

8 files changed

+45
-32
lines changed

.github/workflows/build-publish.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,48 @@ on:
99
env:
1010
REGISTRY: ghcr.io
1111
IMAGE_NAME: ghcr.io/${{ github.repository }}
12+
LATEST_VERSION: 4.4.2
1213

1314
jobs:
1415
build:
1516
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
id-token: write
21+
22+
strategy:
23+
matrix:
24+
r_version:
25+
- 4.2.3
26+
- 4.3.3
27+
- 4.4.2
1628

1729
steps:
1830
- name: Checkout repository
19-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/[email protected]
2035

2136
- name: Build
22-
run: make --no-builtin-rules build
37+
run: make --no-builtin-rules build R_VERSION=${{ matrix.r_version }}
2338

2439
- name: Unit Tests
25-
run: make --no-builtin-rules test
40+
run: make --no-builtin-rules test R_VERSION=${{ matrix.r_version }}
2641

27-
- name: Log into registry
42+
- name: Log into registry ${{ env.REGISTRY }}
2843
if: github.event_name != 'pull_request'
29-
uses: docker/login-action@v2.0.0
44+
uses: docker/login-action@v3.0.0
3045
with:
3146
registry: ${{ env.REGISTRY }}
3247
username: ${{ github.actor }}
3348
password: ${{ secrets.GITHUB_TOKEN }}
3449

3550
- name: Publish images
3651
if: github.event_name != 'pull_request'
37-
run: make --no-builtin-rules push
52+
run: make --no-builtin-rules push R_VERSION=${{ matrix.r_version }}
53+
54+
- name: Publish latest images
55+
if: github.event_name != 'pull_request' && env.LATEST_VERSION == matrix.r_version
56+
run: make --no-builtin-rules push-latest R_VERSION=${{ matrix.r_version }}

Dockerfile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG UBUNTU_VERSION
1+
ARG UBUNTU_VERSION=latest
22
FROM ubuntu:$UBUNTU_VERSION
33

44
ARG R_VERSION
@@ -27,6 +27,7 @@ RUN apt-get update -q \
2727
gnupg2 \
2828
libbz2-dev \
2929
libcurl4-openssl-dev \
30+
libdeflate-dev \
3031
libicu-dev \
3132
liblzma-dev \
3233
libpcre2-dev \
@@ -36,6 +37,8 @@ RUN apt-get update -q \
3637
libxml2-dev \
3738
locales \
3839
lsb-release \
40+
pandoc \
41+
pandoc-citeproc \
3942
perl \
4043
software-properties-common \
4144
sudo \
@@ -76,17 +79,6 @@ RUN curl -sSL "https://yihui.org/tinytex/install-bin-unix.sh" | sh \
7679
&& /opt/TinyTeX/bin/*/tlmgr option sys_bin /usr/local/bin \
7780
&& /opt/TinyTeX/bin/*/tlmgr path add
7881

79-
# install pandoc
80-
RUN mkdir -p /opt/pandoc \
81-
&& curl -sSL https://files.r-hub.io/pandoc/linux-64/pandoc.gz -o /opt/pandoc/pandoc.gz \
82-
&& gzip -d /opt/pandoc/pandoc.gz \
83-
&& chmod +x /opt/pandoc/pandoc \
84-
&& ln -s /opt/pandoc/pandoc /usr/bin/pandoc \
85-
&& curl -sSL https://files.r-hub.io/pandoc/linux-64/pandoc-citeproc.gz -o /opt/pandoc/pandoc-citeproc.gz \
86-
&& gzip -d /opt/pandoc/pandoc-citeproc.gz \
87-
&& chmod +x /opt/pandoc/pandoc-citeproc \
88-
&& ln -s /opt/pandoc/pandoc-citeproc /usr/bin/pandoc-citeproc
89-
9082
# install R
9183
RUN apt-get update -q \
9284
&& apt-get install -qy --no-install-recommends \

Dockerfile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE
1+
ARG BASE_IMAGE=provide-via-build-arg
22

33
FROM $BASE_IMAGE
44

Dockerfile.plumber

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE
1+
ARG BASE_IMAGE=provide-via-build-arg
22

33
FROM $BASE_IMAGE
44

Dockerfile.shiny

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE
1+
ARG BASE_IMAGE=provide-via-build-arg
22

33
FROM $BASE_IMAGE
44

Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export
1010

1111
.PHONY: build
1212
build:
13-
1413
# "base" image
1514
docker build \
1615
--pull \
@@ -48,7 +47,6 @@ build:
4847

4948
.PHONY: test
5049
test:
51-
5250
# smoke test images, before running units
5351
docker run --tty --rm $(IMAGE_TAG) R --no-save -e "capabilities()"
5452
docker run --tty --rm $(IMAGE_TAG)-build R --no-save -e "capabilities()"
@@ -60,18 +58,19 @@ test:
6058

6159
.PHONY: push
6260
push:
63-
64-
docker push $(IMAGE_NAME):latest
61+
# image names contain R version
6562
docker push $(IMAGE_TAG)
66-
67-
docker push $(IMAGE_NAME):build
6863
docker push $(IMAGE_TAG)-build
69-
70-
docker push $(IMAGE_NAME):shiny
7164
docker push $(IMAGE_TAG)-shiny
65+
docker push $(IMAGE_TAG)-plumber
7266

67+
.PHONY: push-latest
68+
push-latest:
69+
# images labelled as "latest"
70+
docker push $(IMAGE_NAME):latest
71+
docker push $(IMAGE_NAME):build
72+
docker push $(IMAGE_NAME):shiny
7373
docker push $(IMAGE_NAME):plumber
74-
docker push $(IMAGE_TAG)-plumber
7574

7675
# adapted from https://stackoverflow.com/a/48782113/30521
7776
env-%:

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ available on [GitHub Container Registry][ghcr], including:
374374

375375
| Ubuntu Version | R Version | Base Tag | Build Tag | Shiny Tag | Plumber Tag |
376376
|----------------|-----------|---------------|---------------|---------------|-----------------|
377-
| `22.04` | `4.2.2` | `latest` | `build` | `shiny` | `plumber` |
377+
| `22.04` | `4.4.2` | `latest` | `build` | `shiny` | `plumber` |
378+
| `22.04` | `4.4.2` | | `4.4.2-build` | `4.4.2-shiny` | `4.4.2-plumber` |
379+
| `22.04` | `4.3.3` | | `4.3.3-build` | `4.3.3-shiny` | `4.3.3-plumber` |
380+
| `22.04` | `4.2.3` | | `4.2.3-build` | `4.2.3-shiny` | `4.2.3-plumber` |
378381
| `22.04` | `4.2.2` | | `4.2.2-build` | `4.2.2-shiny` | `4.2.2-plumber` |
379382
| `22.04` | `4.2.1` | | `4.2.1-build` | `4.2.1-shiny` | `4.2.1-plumber` |
380383

test/units/test.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tryCatch(capabilities(), warning = function(w) {
4747
# Check graphics devices
4848
# https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/Devices.html
4949
for (dev_name in c("png", "jpeg", "tiff", "svg", "bmp", "pdf", "postscript",
50-
"xfig", "pictex", "cairo_pdf", "cairo_ps")) {
50+
"cairo_pdf", "cairo_ps")) {
5151
# Skip unsupported graphics devices (e.g. tiff in R >= 3.3 on CentOS 6)
5252
if (dev_name %in% names(capabilities()) && capabilities(dev_name) == FALSE) {
5353
next

0 commit comments

Comments
 (0)