Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Nov 28, 2024
0 parents commit 6c3a0d9
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
bionic:
command: /package.sh
environment:
- R_VERSION=${R_VERSION}
build:
context: .
dockerfile: dockerfiles/bionic/Dockerfile
image: r-hub/r-glibc-bionic
volumes:
- ./output:/output
137 changes: 137 additions & 0 deletions dockerfiles/bionic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# -*- Dockerfile -*-

FROM ubuntu:18.04 AS build

USER root
WORKDIR /root

RUN apt-get update && \
apt-get install -y build-essential g++ gfortran curl \
pkg-config

RUN curl -LO https://cran.r-project.org/src/base/R-4/R-4.4.2.tar.gz
RUN tar xzf R-4.4.2.tar.gz

ENV TZ=UTC

RUN apt-get update && \
apt-get install -y libreadline-dev zlib1g-dev libbz2-dev \
liblzma-dev libpcre2-dev libssl-dev libopenblas-dev \
libjpeg-turbo8-dev libpng-dev libtiff-dev libicu-dev \
libcairo-dev libffi-dev

# roll our own libcurl, the original has way too many depe
RUN curl -LO https://curl.haxx.se/download/curl-8.11.0.tar.gz
RUN tar xzf curl-*.tar.gz && rm curl-*.tar.gz
RUN cd curl-* && \
LDFLAGS="-L/opt/r-lib/lib" \
./configure --prefix=/opt/r-lib \
--enable-static --disable-shared --with-openssl \
--without-libpsl --without-brotli; \
make && \
make install

# Need to rebuild
# - openssl w/ a patch from
# https://github.com/Romain-Geissler-1A/openssl/commit/37748d7e6e24247729812b9b31f5ae697a46d2a6
# - libtiff with
# --- tiff-4.0.9/debian/rules 2018-04-15 18:13:42.000000000 +0000
# +++ tiff-4.0.9-new/debian/rules 2024-11-27 16:25:15.920000132 +0000
# @@ -6,7 +6,8 @@
#
# # Enable all hardening options.
# export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# -export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -D_REENTRANT
# +export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -D_REENTRANT -fPIC
# +export DEB_CXXFLAGS_MAINT_APPEND = -fPIC
# export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
#
# # Variables used by cdbs
RUN curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libssl-dev_1.1.1-1ubuntu2.1.18.04.23_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libssl1.1_1.1.1-1ubuntu2.1.18.04.23_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/openssl_1.1.1-1ubuntu2.1.18.04.23_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libtiff-dev_4.0.9-5ubuntu0.10_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libtiff5-dev_4.0.9-5ubuntu0.10_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libtiff5_4.0.9-5ubuntu0.10_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libtiffxx5_4.0.9-5ubuntu0.10_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libfreetype6-dev_2.8.1-2ubuntu2.2_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libfreetype6_2.8.1-2ubuntu2.2_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libpng-dev_1.6.34-1ubuntu0.18.04.2_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libpng-tools_1.6.34-1ubuntu0.18.04.2_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libpng16-16_1.6.34-1ubuntu0.18.04.2_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libpixman-1-0_0.34.0-2ubuntu0.1_arm64.deb && \
curl -LO https://github.com/r-hub/r-musl/releases/download/0.0.1/libpixman-1-dev_0.34.0-2ubuntu0.1_arm64.deb && \
apt-get update && \
apt-get install -y libjbig-dev libjbig0 libjpeg-dev libjpeg8 && \
dpkg -i ./libssl-dev* ./libssl1* ./openssl* ./libtiff* libfreetype* libpng* libpixman* && \
rm *.deb

RUN mkdir -p /opt/r-lib/lib && \
cp `find /usr/ -name libgfortran.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name 'libstdc++.a'` /opt/r-lib/lib/ && \
cp `find /usr/ -name libgomp.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libreadline.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libz.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libbz2.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name liblzma.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name "libpcre2*.a"` /opt/r-lib/lib/ && \
cp `find /usr/ -name libssl.a` `find /usr/ -name libcrypto.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libopenblas.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libtinfo.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libjpeg.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libpng.a` /opt/r-lib/lib/ && \
cp `find /usr/ -name libtiff.a` /opt/r-lib/lib/ && \
cp `dpkg -L libicu-dev | grep '\.a$'` /opt/r-lib/lib/ && \
cp `find /usr -name libcairo.a` /opt/r-lib/lib/ &&\
cp `find /usr -name libffi.a` /opt/r-lib/lib/ && \
cp `find /usr -name libjbig.a` /opt/r-lib/lib/ && \
cp `find /usr -name libpng16.a` /opt/r-lib/lib/ && \
cp `find /usr -name libpixman-1.a` /opt/r-lib/lib/ && \
cp `find /usr -name libfontconfig.a` /opt/r-lib/lib/ && \
cp `find /usr -name libfreetype.a` /opt/r-lib/lib/ && \
cp `find /usr -name libexpat.a` /opt/r-lib/lib/ && \
cp `find /usr -name libpng16.a` /opt/r-lib/lib/

# embed which into R, because it is very much needed, but some
# minimal Docker images don't have it
RUN curl -LO https://github.com/r-hub/r-musl/releases/download/v3.19/$(arch)/which-r-2.21-r4.apk && \
tar xzf which-*.apk opt/r-lib/bin/which && \
mkdir -p /opt/R/4.4.2-static/lib/R/tools && \
cp opt/r-lib/bin/which /opt/R/4.4.2-static/lib/R/tools

COPY dockerfiles/bionic/R-4.4.2.patch .
RUN cd R-4.4.2 && patch -p1 < ../R-4.4.2.patch
RUN cd R-4.4.2 && \
PATH="/opt/R/4.4.2-static/lib/R/tools:/opt/r-lib/bin:$PATH" \
./configure --with-internal-tzcode --prefix=/opt/R/4.4.2-static --with-x=no \
--with-blas --with-lapack --enable-BLAS-shlib=no \
--with-included-gettext \
--with-static-cairo \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/r-lib/lib/pkgconfig" \
BLAS_LIBS="-lopenblas -lpthread" \
CPPFLAGS=-I/opt/r-lib/include \
LDFLAGS=-L/opt/r-lib/lib

RUN cd R-4.4.2 && make
RUN cd R-4.4.2 && make install

# patch to embed CA certs
RUN curl -L https://curl.se/ca/cacert.pem -o /opt/R/4.4.2-static/lib/R/share/curl-ca-bundle.crt
RUN echo "CURL_CA_BUNDLE=${CURL_CA_BUNDLE-/opt/R/4.4.2-static/lib/R/share/curl-ca-bundle.crt}" \
>> /opt/R/4.4.2-static/lib/R/etc/Renviron

# strip
RUN for f in `find /opt/R/4.4.2-static/ -executable -type f `; do strip -x "$f" || true; done

FROM ubuntu:18.04 AS final
COPY --from=build /opt/R/4.4.2-static /opt/R/4.4.2-static

USER root
WORKDIR /root

ENV TZ=UTC

# Some of this info is shown on the GH packages pages
LABEL org.opencontainers.image.source="https://github.com/r-hub/r-musl"
LABEL org.opencontainers.image.description="Self-contained R build for GNU/Linux"
LABEL org.opencontainers.image.authors="https://github.com/gaborcsardi"
20 changes: 20 additions & 0 deletions dockerfiles/bionic/R-4.4.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- R-4.4.2-old/configure 2024-10-31 08:01:28.000000000 +0000
+++ R-4.4.2/configure 2024-11-27 06:38:21.520000365 +0000
@@ -49650,7 +49650,7 @@
printf %s "(cached) " >&6
else case e in #(
e) r_save_LIBS="${LIBS}"
-LIBS="${LIBS} -licuuc -licui18n"
+LIBS="${LIBS} -licui18n -licuuc -licudata -lstdc++ -lm -ldl"
if test "$cross_compiling" = yes
then :
r_cv_icu=no
@@ -49702,7 +49702,7 @@

printf "%s\n" "#define USE_ICU 1" >>confdefs.h

- LIBS="${LIBS} -licuuc -licui18n"
+ LIBS="${LIBS} -licui18n -licuuc -licudata -lstdc++ -lm -ldl"
else
use_ICU=no
fi

0 comments on commit 6c3a0d9

Please sign in to comment.