Skip to content

Commit

Permalink
Merge pull request #29 from virtualstaticvoid/feat/build-multiple-r-v…
Browse files Browse the repository at this point in the history
…ersions

Add support for building multiple r versions
  • Loading branch information
virtualstaticvoid authored Nov 13, 2024
2 parents 39933ac + 5129611 commit 60c9651
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 32 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,48 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository }}
LATEST_VERSION: 4.4.2

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

strategy:
matrix:
r_version:
- 4.2.3
- 4.3.3
- 4.4.2

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Build
run: make --no-builtin-rules build
run: make --no-builtin-rules build R_VERSION=${{ matrix.r_version }}

- name: Unit Tests
run: make --no-builtin-rules test
run: make --no-builtin-rules test R_VERSION=${{ matrix.r_version }}

- name: Log into registry
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2.0.0
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish images
if: github.event_name != 'pull_request'
run: make --no-builtin-rules push
run: make --no-builtin-rules push R_VERSION=${{ matrix.r_version }}

- name: Publish latest images
if: github.event_name != 'pull_request' && env.LATEST_VERSION == matrix.r_version
run: make --no-builtin-rules push-latest R_VERSION=${{ matrix.r_version }}
16 changes: 4 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG UBUNTU_VERSION
ARG UBUNTU_VERSION=latest
FROM ubuntu:$UBUNTU_VERSION

ARG R_VERSION
Expand Down Expand Up @@ -27,6 +27,7 @@ RUN apt-get update -q \
gnupg2 \
libbz2-dev \
libcurl4-openssl-dev \
libdeflate-dev \
libicu-dev \
liblzma-dev \
libpcre2-dev \
Expand All @@ -36,6 +37,8 @@ RUN apt-get update -q \
libxml2-dev \
locales \
lsb-release \
pandoc \
pandoc-citeproc \
perl \
software-properties-common \
sudo \
Expand Down Expand Up @@ -76,17 +79,6 @@ RUN curl -sSL "https://yihui.org/tinytex/install-bin-unix.sh" | sh \
&& /opt/TinyTeX/bin/*/tlmgr option sys_bin /usr/local/bin \
&& /opt/TinyTeX/bin/*/tlmgr path add

# install pandoc
RUN mkdir -p /opt/pandoc \
&& curl -sSL https://files.r-hub.io/pandoc/linux-64/pandoc.gz -o /opt/pandoc/pandoc.gz \
&& gzip -d /opt/pandoc/pandoc.gz \
&& chmod +x /opt/pandoc/pandoc \
&& ln -s /opt/pandoc/pandoc /usr/bin/pandoc \
&& curl -sSL https://files.r-hub.io/pandoc/linux-64/pandoc-citeproc.gz -o /opt/pandoc/pandoc-citeproc.gz \
&& gzip -d /opt/pandoc/pandoc-citeproc.gz \
&& chmod +x /opt/pandoc/pandoc-citeproc \
&& ln -s /opt/pandoc/pandoc-citeproc /usr/bin/pandoc-citeproc

# install R
RUN apt-get update -q \
&& apt-get install -qy --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE
ARG BASE_IMAGE=provide-via-build-arg

FROM $BASE_IMAGE

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.plumber
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE
ARG BASE_IMAGE=provide-via-build-arg

FROM $BASE_IMAGE

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.shiny
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE
ARG BASE_IMAGE=provide-via-build-arg

FROM $BASE_IMAGE

Expand Down
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export

.PHONY: build
build:

# "base" image
docker build \
--pull \
Expand Down Expand Up @@ -48,7 +47,6 @@ build:

.PHONY: test
test:

# smoke test images, before running units
docker run --tty --rm $(IMAGE_TAG) R --no-save -e "capabilities()"
docker run --tty --rm $(IMAGE_TAG)-build R --no-save -e "capabilities()"
Expand All @@ -60,18 +58,19 @@ test:

.PHONY: push
push:

docker push $(IMAGE_NAME):latest
# image names contain R version
docker push $(IMAGE_TAG)

docker push $(IMAGE_NAME):build
docker push $(IMAGE_TAG)-build

docker push $(IMAGE_NAME):shiny
docker push $(IMAGE_TAG)-shiny
docker push $(IMAGE_TAG)-plumber

.PHONY: push-latest
push-latest:
# images labelled as "latest"
docker push $(IMAGE_NAME):latest
docker push $(IMAGE_NAME):build
docker push $(IMAGE_NAME):shiny
docker push $(IMAGE_NAME):plumber
docker push $(IMAGE_TAG)-plumber

# adapted from https://stackoverflow.com/a/48782113/30521
env-%:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ available on [GitHub Container Registry][ghcr], including:

| Ubuntu Version | R Version | Base Tag | Build Tag | Shiny Tag | Plumber Tag |
|----------------|-----------|---------------|---------------|---------------|-----------------|
| `22.04` | `4.2.2` | `latest` | `build` | `shiny` | `plumber` |
| `22.04` | `4.4.2` | `latest` | `build` | `shiny` | `plumber` |
| `22.04` | `4.4.2` | | `4.4.2-build` | `4.4.2-shiny` | `4.4.2-plumber` |
| `22.04` | `4.3.3` | | `4.3.3-build` | `4.3.3-shiny` | `4.3.3-plumber` |
| `22.04` | `4.2.3` | | `4.2.3-build` | `4.2.3-shiny` | `4.2.3-plumber` |
| `22.04` | `4.2.2` | | `4.2.2-build` | `4.2.2-shiny` | `4.2.2-plumber` |
| `22.04` | `4.2.1` | | `4.2.1-build` | `4.2.1-shiny` | `4.2.1-plumber` |

Expand Down
2 changes: 1 addition & 1 deletion test/units/test.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tryCatch(capabilities(), warning = function(w) {
# Check graphics devices
# https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/Devices.html
for (dev_name in c("png", "jpeg", "tiff", "svg", "bmp", "pdf", "postscript",
"xfig", "pictex", "cairo_pdf", "cairo_ps")) {
"cairo_pdf", "cairo_ps")) {
# Skip unsupported graphics devices (e.g. tiff in R >= 3.3 on CentOS 6)
if (dev_name %in% names(capabilities()) && capabilities(dev_name) == FALSE) {
next
Expand Down

0 comments on commit 60c9651

Please sign in to comment.