FROM balenalib/raspberrypi3-debian:stretch

RUN [ "cross-build-start" ]

RUN apt-get update \
 && apt-get -y install wget curl build-essential libssl-dev libffi-dev \
 && apt-get clean

# Prepare environment
RUN mkdir /freqtrade
WORKDIR /freqtrade

# Install TA-lib
COPY build_helpers/ta-lib-0.4.0-src.tar.gz /freqtrade/
RUN tar -xzf /freqtrade/ta-lib-0.4.0-src.tar.gz \
 && cd /freqtrade/ta-lib/ \
 && ./configure \
 && make \
 && make install \
 && rm /freqtrade/ta-lib-0.4.0-src.tar.gz

ENV LD_LIBRARY_PATH /usr/local/lib

# Install berryconda
RUN wget -q https://github.com/jjhelmus/berryconda/releases/download/v2.0.0/Berryconda3-2.0.0-Linux-armv7l.sh \
 && bash ./Berryconda3-2.0.0-Linux-armv7l.sh -b \
 && rm Berryconda3-2.0.0-Linux-armv7l.sh

# Install dependencies
COPY requirements-common.txt /freqtrade/
RUN ~/berryconda3/bin/conda install -y numpy pandas \
 && ~/berryconda3/bin/pip install -r requirements-common.txt --no-cache-dir

# Install and execute
COPY . /freqtrade/
RUN ~/berryconda3/bin/pip install -e . --no-cache-dir

RUN [ "cross-build-end" ]

ENTRYPOINT ["/root/berryconda3/bin/python","./freqtrade/main.py"]
CMD [ "trade" ]
