diff --git a/ci/docker/alpine-linux-3.22-r.dockerfile b/ci/docker/alpine-linux-3.22-r.dockerfile new file mode 100644 index 00000000000..5a6206a2da2 --- /dev/null +++ b/ci/docker/alpine-linux-3.22-r.dockerfile @@ -0,0 +1,82 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Minimal Alpine Linux container with R for testing Arrow R package +# on musl libc (CRAN runs checks on Alpine Linux 3.22) +# Replicates CRAN's Alpine environment as closely as possible + +ARG arch=amd64 +FROM ${arch}/alpine:3.22 + +# Install R and essential build tools +# Note: bash is needed for Arrow CI scripts, even though CRAN's Alpine uses BusyBox +RUN apk add \ + R \ + R-dev \ + R-doc \ + bash \ + cmake \ + curl-dev \ + g++ \ + gcc \ + git \ + make \ + musl-locales \ + openssl-dev \ + pkgconfig \ + zlib-dev && \ + rm -rf /var/cache/apk/* && \ + ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \ + echo "Etc/UTC" > /etc/timezone + +# Set locale and timezone +ENV LANG=C.UTF-8 \ + LC_COLLATE=C \ + MUSL_LOCPATH=/usr/share/i18n/locales/musl + +# Set CRAN repo +RUN echo 'options(repos = c(CRAN = "https://cran.rstudio.com"))' >> /usr/lib/R/etc/Rprofile.site + +# Install pak for package management (following rhub pattern) +RUN R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "devel", .Platform$pkgType, R.Version()$os, R.Version()$arch))' + +# Enable automatic system requirements installation +ENV PKG_SYSREQS=true \ + R_PKG_SYSREQS2=true + +# Set up parallel compilation +RUN echo "MAKEFLAGS=-j$(R -s -e 'cat(parallel::detectCores())')" >> /usr/lib/R/etc/Renviron.site + +# Configure image and install Arrow-specific tooling +COPY ci/scripts/r_docker_configure.sh /arrow/ci/scripts/ +COPY ci/etc/rprofile /arrow/ci/etc/ +COPY ci/scripts/r_install_system_dependencies.sh /arrow/ci/scripts/ +COPY ci/scripts/install_minio.sh /arrow/ci/scripts/ +COPY ci/scripts/install_gcs_testbench.sh /arrow/ci/scripts/ +RUN /arrow/ci/scripts/r_docker_configure.sh + +# Install sccache +COPY ci/scripts/install_sccache.sh /arrow/ci/scripts/ +RUN /arrow/ci/scripts/install_sccache.sh unknown-linux-musl /usr/local/bin + +# Install R package dependencies +COPY ci/scripts/r_deps.sh /arrow/ci/scripts/ +COPY r/DESCRIPTION /arrow/r/ +RUN /arrow/ci/scripts/r_deps.sh /arrow + +# Verify R works and this is musl +RUN R --version && ldd --version 2>&1 | grep -q musl diff --git a/compose.yaml b/compose.yaml index 5f32e4f9b3c..5c72d5449ea 100644 --- a/compose.yaml +++ b/compose.yaml @@ -114,6 +114,7 @@ x-hierarchy: # service entry, so any new image/service must be listed here. - almalinux-verify-rc - alpine-linux-cpp + - alpine-linux-r - centos-cpp-static - conda: - conda-cpp: @@ -246,6 +247,35 @@ services: /arrow/ci/scripts/cpp_build.sh /arrow /build && /arrow/ci/scripts/cpp_test.sh /arrow /build" + alpine-linux-r: + # Usage: + # docker compose build alpine-linux-r + # docker compose run alpine-linux-r + # Tests R package installation on musl (Alpine Linux) for CRAN checks. + # R package builds C++ from source (bundled RE2 2023-03-01 supports musl). + # Parameters: + # ALPINE_LINUX: 3.22 + # R: 4.5 (Alpine's R version) + # ARCH: amd64, arm64v8, ... + image: ${REPO}:${ARCH}-alpine-linux-${ALPINE_LINUX}-r + build: + context: . + dockerfile: ci/docker/alpine-linux-${ALPINE_LINUX}-r.dockerfile + cache_from: + - ${REPO}:${ARCH}-alpine-linux-${ALPINE_LINUX}-r + args: + arch: ${ARCH} + shm_size: *shm-size + environment: + <<: [*common, *sccache] + LIBARROW_BINARY: "false" + ARROW_SOURCE_HOME: "/arrow" + ARROW_R_DEV: "TRUE" + ARROW_USE_PKG_CONFIG: "false" + volumes: + - .:/arrow:delegated + command: /arrow/ci/scripts/r_test.sh /arrow + conda: # Base image for conda builds. # diff --git a/dev/tasks/tasks.yml b/dev/tasks/tasks.yml index 6cf11d66b9f..ada8808b52c 100644 --- a/dev/tasks/tasks.yml +++ b/dev/tasks/tasks.yml @@ -669,6 +669,12 @@ tasks: ci: github template: r/github.linux.cran.yml + test-r-alpine-linux: + ci: github + template: docker-tests/github.linux.yml + params: + image: alpine-linux-r + test-r-macos-as-cran: ci: github template: r/github.macos.cran.yml