Skip to content

Commit

Permalink
add R building machinery
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert authored and asottile committed Sep 3, 2021
1 parent fe493e7 commit 69015b7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
32 changes: 32 additions & 0 deletions languages/R/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ubuntu:focal
RUN : \
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
&& sed -i 's/^# deb-src /deb-src /' /etc/apt/sources.list \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends build-dep r-base \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG R_VERSION
ARG R_SHA256
RUN : \
&& set -x \
&& mkdir /tmp/r \
&& cd /tmp/r \
&& curl --silent --location --output r.tgz "https://cran.rstudio.com/src/base/R-${R_VERSION%%.*}/R-$R_VERSION.tar.gz" \
&& echo "${R_SHA256} r.tgz" | sha256sum --check \
&& tar -xf r.tgz \
&& cd "R-${R_VERSION}" \
&& mkdir -p /opt/r/ \
&& ./configure \
--prefix=/opt/r/ \
--enable-memory-profiling \
--enable-R-shlib \
--with-blas \
--with-lapack \
--without-recommended-packages \
&& make \
&& make install \
&& rm -rf /tmp/r \
&& :
25 changes: 25 additions & 0 deletions languages/R/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euxo pipefail

R_VERSION=4.0.2
R_SHA256=d3bceab364da0876625e4097808b42512395fdf41292f4915ab1fd257c1bbe75

podman build \
--build-arg=R_VERSION="$R_VERSION" \
--build-arg=R_SHA256="$R_SHA256" \
-t runner-image-r .

cid="$(podman create runner-image-r sleep infinity)"
trap 'podman rm -f "$cid"' exit

podman start "$cid"
podman exec "$cid" rm -rf /opt/r/lib/R/doc /opt/r/share
podman exec "$cid" \
tar -C /opt/r \
--sort=name \
--mtime="1970-01-01 00:00:00Z" \
--owner=0 --group=0 --numeric-owner \
-czf /tmp/r.tgz .

podman cp "$cid:/tmp/r.tgz" "r-${R_VERSION}.tgz"
sha256sum "r-${R_VERSION}.tgz"

0 comments on commit 69015b7

Please sign in to comment.