# Dockerfile for building a LEMMI container for ganon
# It is based on the biobox idea, see bioboxes.org
# No validation using yaml files required here yet

### You can pick another distribution if needed, but ubuntu is a safe bet
FROM ubuntu
####
#
# 1) install the commonly required packages here
#

RUN sleep 1
RUN apt-get update -y --fix-missing
RUN apt-get install build-essential -y
RUN apt-get install cmake -y
RUN apt-get install wget -y
RUN apt-get install python -y
RUN apt-get install python-pip -y
RUN apt-get install python3-pip -y
RUN apt-get install git -y
RUN apt-get install python3 -y
RUN pip3 install binpacking==1.3

# Anaconda installing
RUN wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
RUN bash Anaconda3-5.0.1-Linux-x86_64.sh -b
RUN rm Anaconda3-5.0.1-Linux-x86_64.sh

# Set path to conda
ENV PATH /root/anaconda3/bin:$PATH

RUN conda config --append channels quantstack

RUN conda create -n gcc7 -c quantstack libgcc-7

RUN /bin/bash -c "source activate gcc7"

RUN git clone --recurse-submodules https://github.com/pirovc/ganon.git

RUN pip install binpacking==1.3

RUN git clone -b v0.1 https://github.com/pirovc/taxsbp/

WORKDIR /ganon

RUN git checkout 3a0b87fcda1f47455b4eefc6c47989b0c601f16f

RUN mkdir build

WORKDIR /ganon/build

RUN apt-get remove cmake -y

RUN apt-get update -y

RUN apt-get install cmake -y

# if compilation issues
#RUN sed -i 's/add_compile_options( -static -msse4.2 -march=native )/add_compile_options( -static -march=native )/g' /ganon/CMakeLists.txt
RUN /bin/bash -c "cmake -DCMAKE_BUILD_TYPE=Release .."

RUN /bin/bash -c "make"

# do not touch this one
ADD entry /usr/local/bin/

### Modify the file, but keep it here.
ADD Taskfile /


### ADD whatever else you need here
# be careful to chmod +x bash file if you call them ./script.sh
# these are scripts to convert the input fasta provided by the LEMMI bench platform into fasta that metacache can process
# and scripts that convert the metacache outputs into CAMI profiling and CAMI binning files, expected as output.
#
# To deal with the input/training content, be careful not to use command like ls, rm, that have a limited list of argument. use find -exec or find | xargs
# as it will have to deal with more than 100,000 files during benchmark. Try to parallelize as much as possible to use all CPU provided, as all steps will affect the runtime.

ADD scripts/extract_inputs.sh /
ADD scripts/gunzip.sh /
ADD scripts/prepare_input_files.sh /
ADD scripts/prepare_bins.sh /
ADD scripts/filter_reads.py /

# Starting point when you call docker run analysis or docker run build_ref
# Do not change this
WORKDIR /bbx/tmp
ENV PATH /taxsbp/:/taxsbp/scripts:$PATH
ENTRYPOINT ["entry"]
