Skip to content

Instantly share code, notes, and snippets.

@xiaodaigh
Created December 30, 2019 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaodaigh/5ad6fc392e9adff134a4b8e86172993c to your computer and use it in GitHub Desktop.
Save xiaodaigh/5ad6fc392e9adff134a4b8e86172993c to your computer and use it in GitHub Desktop.
Dockerfile for minimal r and python docker with arrow
FROM python:3.7-alpine3.10
RUN apk add --no-cache \
build-base \
cmake \
bash \
boost-dev \
autoconf \
zlib-dev \
flex \
bison
RUN pip install --no-cache-dir six pytest numpy cython
RUN pip install --no-cache-dir pandas
ARG ARROW_VERSION=0.12.0
ARG ARROW_SHA1=2ede75769e12df972f0acdfddd53ab15d11e0ac2
ARG ARROW_BUILD_TYPE=release
ENV ARROW_HOME=/usr/local \
PARQUET_HOME=/usr/local
#Download and build apache-arrow
RUN mkdir /arrow \
&& apk add --no-cache curl \
&& curl -o /tmp/apache-arrow.tar.gz -SL https://github.com/apache/arrow/archive/apache-arrow-${ARROW_VERSION}.tar.gz \
&& echo "$ARROW_SHA1 *apache-arrow.tar.gz" | sha1sum /tmp/apache-arrow.tar.gz \
&& tar -xvf /tmp/apache-arrow.tar.gz -C /arrow --strip-components 1 \
&& mkdir -p /arrow/cpp/build \
&& cd /arrow/cpp/build \
&& cmake -DCMAKE_BUILD_TYPE=$ARROW_BUILD_TYPE \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=$ARROW_HOME \
-DARROW_PARQUET=on \
-DARROW_PYTHON=on \
-DARROW_PLASMA=on \
-DARROW_BUILD_TESTS=OFF \
.. \
&& make -j$(nproc) \
&& make install \
&& cd /arrow/python \
&& python setup.py build_ext --build-type=$ARROW_BUILD_TYPE --with-parquet \
&& python setup.py install \
&& rm -rf /arrow /tmp/apache-arrow.tar.gz
# install R
ENV _R_SHLIB_STRIP_=true
COPY remotes.R /usr/local/bin/
COPY installr /usr/local/bin/
RUN apk update && \
apk add gcc musl-dev gfortran g++ zlib-dev bzip2-dev xz-dev pcre-dev \
curl-dev make perl && \
##
wget https://cran.r-project.org/src/base/R-3/R-3.6.2.tar.gz && \
tar xzf R-3.6.2.tar.gz && \
##
cd R-3.6.2 && \
CXXFLAGS=-D__MUSL__ ./configure --with-recommended-packages=no \
--with-readline=no --with-x=no --enable-java=no \
--disable-openmp && \
make && \
make install && \
##
rm -rf /R-3.6.2* && \
##
strip -x /usr/local/lib/R/bin/exec/R && \
strip -x /usr/local/lib/R/lib/* && \
find /usr/local/lib/R -name "*.so" -exec strip -x \{\} \; && \
##
rm -rf /usr/local/lib/R/library/translations && \
rm -rf /usr/local/lib/R/doc && \
mkdir -p /usr/local/lib/R/doc/html && \
find /usr/local/lib/R/library -name help | xargs rm -rf && \
## \
apk add libgfortran xz-libs libcurl libpcrecpp libbz2 && \
##
installr disk.frame && \
apk del gfortran gcc g++ musl-dev zlib-dev bzip2-dev xz-dev curl-dev \
pcre-dev perl \
build-base \
cmake \
bash \
boost-dev\
autoconf \
zlib-dev \
flex \
bison \
curl && \
apk add libgfortran xz-libs libcurl libpcrecpp libbz2 && \
rm -rf /var/cache/apk/*
RUN touch /usr/local/lib/R/doc/html/R.css
CMD ["R"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment