Skip to content

Commit

Permalink
Merge pull request #313 from ens-lgil/feature/docker_95_v3
Browse files Browse the repository at this point in the history
More compact Dockerfile in order to reduce the number of layers to bu…
  • Loading branch information
aparton authored Nov 2, 2018
2 parents 388098d + 7d5b822 commit 6cde6b6
Showing 1 changed file with 50 additions and 55 deletions.
105 changes: 50 additions & 55 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
###################################################
FROM ubuntu:16.04 as builder

# update aptitude and install some required packages
# Update aptitude and install some required packages
# a lot of them are required for Bio::DB::BigFile
RUN apt-get update && apt-get -y install \
build-essential \
Expand All @@ -23,34 +23,26 @@ ENV HTSLIB_DIR $OPT_SRC/htslib
# Working directory
WORKDIR $OPT_SRC

# Clone/download repositories/libraries
# Clone ensembl git repository and extract useful ensemb core file
RUN git clone --depth 1 https://github.com/Ensembl/ensembl.git && \
cp ensembl/cpanfile ensembl_cpanfile && \
rm -rf ensembl

# Clone ensembl-vep git repository
RUN git clone --depth 1 https://github.com/Ensembl/ensembl-vep.git && chmod u+x ensembl-vep/*.pl

# Clone ensembl-variation git repository
RUN git clone --depth 1 https://github.com/Ensembl/ensembl-variation.git && \
rm -rf ensembl && \
# Clone ensembl-vep git repository
git clone --depth 1 https://github.com/Ensembl/ensembl-vep.git && chmod u+x ensembl-vep/*.pl && \
# Clone ensembl-variation git repository and compile C code
git clone --depth 1 https://github.com/Ensembl/ensembl-variation.git && \
mkdir var_c_code && \
cp ensembl-variation/C_code/*.c ensembl-variation/C_code/Makefile var_c_code/ && \
rm -rf ensembl-variation && \
chmod u+x var_c_code/*

# Download bioperl-ext
RUN git clone --depth 1 https://github.com/bioperl/bioperl-ext.git
WORKDIR bioperl-ext/Bio/Ext/Align/
RUN perl -pi -e"s|(cd libs.+)CFLAGS=\\\'|\$1CFLAGS=\\\'-fPIC |" Makefile.PL

# Download ensembl-xs
WORKDIR $OPT_SRC
RUN wget https://github.com/Ensembl/ensembl-xs/archive/2.3.2.zip -O ensembl-xs.zip && \
unzip -q ensembl-xs.zip && mv ensembl-xs-2.3.2 ensembl-xs && rm -rf ensembl-xs.zip

# Clone/Download other repositories
# bioperl-live is needed so the cpanm dependencies installation from the ensembl-vep/cpanfile file takes less disk space
RUN ensembl-vep/travisci/get_dependencies.sh && mv bioperl-live-release-1-6-924 bioperl-live
chmod u+x var_c_code/* && \
# Clone bioperl-ext git repository
git clone --depth 1 https://github.com/bioperl/bioperl-ext.git && \
# Download ensembl-xs
wget https://github.com/Ensembl/ensembl-xs/archive/2.3.2.zip -O ensembl-xs.zip && \
unzip -q ensembl-xs.zip && mv ensembl-xs-2.3.2 ensembl-xs && rm -rf ensembl-xs.zip && \
# Clone/Download other repositories: bioperl-live is needed so the cpanm dependencies installation from the ensembl-vep/cpanfile file takes less disk space
ensembl-vep/travisci/get_dependencies.sh && mv bioperl-live-release-1-6-924 bioperl-live

# A lot of cleanup on the imported libraries, in order to reduce the docker image
RUN rm -rf Bio-HTS/.git Bio-HTS/Changes Bio-HTS/DISCLAIMER Bio-HTS/README Bio-HTS/scripts Bio-HTS/t Bio-HTS/travisci \
Expand All @@ -59,20 +51,23 @@ RUN rm -rf Bio-HTS/.git Bio-HTS/Changes Bio-HTS/DISCLAIMER Bio-HTS/README Bio-HT
bioperl-live/maintenance bioperl-live/scripts bioperl-live/t bioperl-live/travis_scripts \
ensembl-vep/.git ensembl-vep/docker \
ensembl-xs/.git ensembl-xs/Changes ensembl-xs/INSTALL ensembl-xs/README ensembl-xs/t ensembl-xs/travisci \
htslib/.git htslib/INSTALL htslib/NEWS htslib/README* htslib/test

# Only keep needed kent-335_base libraries for VEP
RUN mv kent-335_base kent-335_base_bak && mkdir -p kent-335_base/src && \
htslib/.git htslib/INSTALL htslib/NEWS htslib/README* htslib/test && \
# Only keep needed kent-335_base libraries for VEP
mv kent-335_base kent-335_base_bak && mkdir -p kent-335_base/src && \
cp -R kent-335_base_bak/build kent-335_base_bak/confs kent-335_base/ && \
cp -R kent-335_base_bak/src/lib kent-335_base_bak/src/inc kent-335_base_bak/src/jkOwnLib kent-335_base/src/ && \
cp kent-335_base_bak/src/*.sh kent-335_base/src/ && \
rm -rf kent-335_base_bak

# install htslib binaries (need bgzip, tabix)
# Setup bioperl-ext
WORKDIR bioperl-ext/Bio/Ext/Align/
RUN perl -pi -e"s|(cd libs.+)CFLAGS=\\\'|\$1CFLAGS=\\\'-fPIC |" Makefile.PL

# Install htslib binaries (need bgzip, tabix)
WORKDIR $HTSLIB_DIR
RUN make install

# compile Variation LD C scripts
# Compile Variation LD C scripts
WORKDIR $OPT_SRC/var_c_code
RUN make && rm -f Makefile *.c

Expand All @@ -82,7 +77,7 @@ RUN make && rm -f Makefile *.c
###################################################
FROM ubuntu:16.04

# update aptitude and install some required packages
# Update aptitude and install some required packages
# a lot of them are required for Bio::DB::BigFile
RUN apt-get update && apt-get -y install \
apache2 \
Expand All @@ -109,48 +104,48 @@ ENV PERL5LIB $PERL5LIB:$OPT_SRC/bioperl-live
ENV HTSLIB_DIR $OPT_SRC/htslib
ENV DEPS $OPT_SRC
ENV PATH $OPT_SRC/ensembl-vep:$OPT_SRC/var_c_code:$PATH
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8

# create vep user
# Create vep user
RUN useradd -r -m -U -d $OPT -s /bin/bash -c "VEP User" -p '' vep && usermod -a -G sudo vep && mkdir -p $OPT_SRC
USER vep

# Copy downloaded libraries (stage 1) to this image (stage 2)
COPY --chown=vep:vep --from=builder $OPT_SRC $OPT_SRC
#############################################################

RUN echo >> $OPT/.profile && \
echo PATH=$PATH:\$PATH >> $OPT/.profile && \
echo export PATH >> $OPT/.profile

# run the complilation/install as root
# Change user to root for the following complilations/installations
USER root
WORKDIR $OPT_SRC
RUN ensembl-vep/travisci/build_c.sh

# install bioperl-ext, faster alignments for haplo

WORKDIR $OPT_SRC
# Install/compile some C libraries
RUN ensembl-vep/travisci/build_c.sh && \
# Install ensembl perl dependencies (cpanm)
cpanm --installdeps --with-recommends --notest --cpanfile ensembl_cpanfile . && \
cpanm --installdeps --with-recommends --notest --cpanfile ensembl-vep/cpanfile . && \
# Configure "locale", see https://github.com/rocker-org/rocker/issues/19
echo "$LANG UTF-8" >> /etc/locale.gen && locale-gen en_US.utf8 && \
/usr/sbin/update-locale LANG=$LANG

# Install bioperl-ext, faster alignments for haplo
WORKDIR $OPT_SRC/bioperl-ext/Bio/Ext/Align/
RUN perl Makefile.PL && make && make install && rm -f Makefile.PL

# install ensembl-xs, faster run using re-implementation in C of some of the Perl subroutines
# Install ensembl-xs, faster run using re-implementation in C of some of the Perl subroutines
WORKDIR $OPT_SRC/ensembl-xs
RUN perl Makefile.PL && make && make install && rm -f Makefile.PL

# install ensembl perl dependencies
WORKDIR $OPT_SRC
RUN cpanm --installdeps --with-recommends --notest --cpanfile ensembl_cpanfile . && \
cpanm --installdeps --with-recommends --notest --cpanfile ensembl-vep/cpanfile .

# configure locale, see https://github.com/rocker-org/rocker/issues/19
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
locale-gen en_US.utf8 && \
/usr/sbin/update-locale LANG=en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8

# switch back to vep user
# Switch back to vep user
USER vep

# run INSTALL.pl and remove the ensemb-vep tests and travis
# Final steps
WORKDIR $OPT_SRC/ensembl-vep
RUN ./INSTALL.pl -a a -l && rm -rf t travisci .travis.yml
# Update bash profile
RUN echo >> $OPT/.profile && \
echo PATH=$PATH:\$PATH >> $OPT/.profile && \
echo export PATH >> $OPT/.profile && \
# Run INSTALL.pl and remove the ensemb-vep tests and travis
./INSTALL.pl -a a -l && rm -rf t travisci .travis.yml

0 comments on commit 6cde6b6

Please sign in to comment.