FROM ubuntu:14.04

ENV PACKAGES make gcc wget libc6-dev zlib1g-dev ca-certificates xz-utils

RUN apt-get update --fix-missing -y && apt-get install -y --no-install-recommends ${PACKAGES}

RUN apt-get install python -y

RUN apt-get update --fix-missing

RUN apt-get install git -y

RUN apt-get install build-essential -y

# Locations for biobox file validator
ENV VALIDATOR /bbx/validator/
ENV BASE_URL https://s3-us-west-1.amazonaws.com/bioboxes-tools/validate-biobox-file
ENV VERSION  0.x.y
RUN mkdir -p ${VALIDATOR}

# download the validate-biobox-file binary and extract it to the directory $VALIDATOR
RUN wget \
      --quiet \
      --output-document -\
      ${BASE_URL}/${VERSION}/validate-biobox-file.tar.xz \
    | tar xJf - \
      --directory ${VALIDATOR} \
      --strip-components=1


RUN git clone https://github.com/infphilo/centrifuge

RUN wget ftp://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump.tar.gz
RUN tar zxvf taxdump.tar.gz
WORKDIR /centrifuge
RUN git checkout 5c51ac6851d40f3ac34d7b0c0834503698b10647
RUN make
RUN make install prefix=/usr/local

ENV CTFG $(pwd)/centrifuge

ENV PATH ${PATH}:${VALIDATOR}:${CTFG}

#ENV CONVERT https://github.com/bronze1man/yaml2json/raw/master/builds/linux_386/yaml2json
# download yaml2json and make it executable
#RUN cd /usr/local/bin && wget --quiet ${CONVERT} && chmod 700 yaml2json

ENV JQ http://stedolan.github.io/jq/download/linux64/jq
# download jq and make it executable
RUN cd /usr/local/bin && wget --quiet ${JQ} && chmod 700 jq

# chmod so it can be run by non root
RUN chmod go+x /usr/local/bin/jq
#RUN chmod go+x /usr/local/bin/yaml2json

ADD yaml2json /usr/local/bin
# Add Taskfile to /
ADD Taskfile /
# Add schema
ADD schema.yaml /
# Add python code
ADD prepare_results.py /
# Add defaut output for the header
ADD empty_out.tsv /
#
ADD fix_head.sh /
ADD prepare_inputs.sh /

# Add assemble script to the directory /usr/local/bin inside the container.
# /usr/local/bin is appended to the $PATH variable what means that every script
# in that directory will be executed in the shell  without providing the path.
ADD entry /usr/local/bin/



WORKDIR /bbx/tmp

ENTRYPOINT ["entry"]
