FROM apache/airflow:2.1.2-python3.8 
#:master-python3.8

USER root

RUN apt-get update && apt-get install -y \
	        python3 \
	        python3-dev \
            libhdf5-serial-dev python-tables \
            bash vim \
	        g++ make wget git curl gcc gnupg2 \
    && rm -rf /var/lib/apt/lists/*

#RUN pip install numpy 

# TA-Lib
#RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz && \
#  tar -xvzf ta-lib-0.4.0-src.tar.gz && \
#  cd ta-lib/ && \
#  ./configure --prefix=/usr && \
#  make && \
#  make install

#RUN rm -R ta-lib ta-lib-0.4.0-src.tar.gz

RUN curl -L https://downloads.sourceforge.net/project/ta-lib/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz | tar xvz

#WORKDIR /ta-lib
# numpy needs to be installed before TA-Lib
RUN pip3 install 'numpy==1.20.3' \
  && cd ta-lib/ \
  && ./configure --prefix=/usr \
  && make \
  && make install \
  && pip3 install 'TA-Lib==0.4.20'

RUN cd .. && rm -rf ta-lib/

USER airflow

COPY requirements.txt /tmp/
RUN pip3 install --requirement /tmp/requirements.txt

ENV PYTHONPATH "${PYTHONPATH}:/usr/local/airflow/dags"

COPY locator.py /home/airflow/.local/lib/python3.8/site-packages/backtrader/plot/locator.py
COPY plot.py /home/airflow/.local/lib/python3.8/site-packages/backtrader/plot/plot.py


