R包的安装往往令人头疼,总是会遇到各种各样的问题,虽然conda 安装R,使得R包安装有了些许方便,但有些时候 conda更改了真正的环境路径,导致R包需要的一些包经常出现找不到的现象,这个时候可能需要重新编译一个R用于安装,但编译又往往限死在root权限,这个时候就可以考虑使用docker来安装棘手的R,整体dockerfile 如下
1.构建dockerfile
FROM java-1.8.0:1.0
MAINTAINER fanxn fanxuning_bio@163.com
LABEL R=4.1.1
ENV PATH /opt/java/bin:$PATH
WORKDIR /soft
RUN yum install -y which libpng-devel libjpeg-devel libtiff-devel cairo-devel readline-devel postgresql-develmysql-devel texlive-latex libxml2-devel zip unzip pandoc
ADD ./pcre-8.40.tar.gz /tmp/
RUN cd /tmp/pcre-8.40 && ./configure --prefix=/soft --enable-utf8 && make -j 3 && make install
ADD ./R-4.1.1.tar.gz /tmp/
RUN cd /tmp/R-4.1.1 && ./configure --prefix=/soft --enable-R-shlib --with-pcre1 --with-libtiff --with-jpeglib \
--with-libpng --with-x && make -j 4 && make install
RUN /soft/bin/Rscript -e "pkgs <- c('ggplot2', 'data.table', 'reshape2', 'dplyr', 'BiocManager','argparse','coin','corrplot','cowplot','dbplyr','devtools','ggplot2','ggplotify','ggpubr','ggsci','ggsignif','mvtnorm','stringr','stringi','sequenza');install.packages(pkgs = pkgs,dependencies = TRUE, repos='https://mirrors.tuna.tsinghua.edu.cn/CRAN/');sapply(pkgs, require, character.only = TRUE)"
RUN echo "options(BioC_mirror='https://mirrors.tuna.tsinghua.edu.cn/bioconductor')" >> ~/.Rprofile && /soft/bin/Rscript -e "BiocManager::install(c('copynumber','GenomicRanges'))"
ADD ./jdk-11_linux-x64_bin.tar.gz /tmp/
RUN cd /tmp/jdk-11/bin/ && \
ln -s /tmp/jdk-11/bin/java /soft/bin/java && \
ln -s /tmp/jdk-11/bin/java /usr/bin/java
# download bedtools static binary to location already in PATH; make /data
RUN cd /soft && \
wget -c https://github.com/arq5x/bedtools2/releases/download/v2.29.2/bedtools.static.binary && \
mv bedtools.static.binary bedtools && \
chmod +x bedtools && \
ln -s /soft/bedtools /usr/bin/bedtools
ENV PATH /soft/bin/:$PATH
网友评论