FROM python:3.7

WORKDIR /project

# Install Python dependencies with apt to ease arm installation
RUN apt-get update && apt-get install -y git libatlas-base-dev gfortran python3-grpcio python3-scipy python3-numpy python3-sklearn python3-llvmlite python3-cffi python3-audioread python3-numba

# Set python path so it can see the debian packages
ENV PYTHONPATH "${PYTHONPATH}":"/usr/lib/python3/dist-packages/"

# Clone tacotron and squeezewave into the container
RUN git clone -q --recursive https://git.technicalincompetence.club/dan/tacotron2.git
RUN git clone https://git.technicalincompetence.club/dan/fastspeech_squeezewave.git

# Copy our files
COPY synthesize.py .
COPY merged.dict_1.1.txt .
COPY requirements.txt .

# Multiplatform work
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log

## Copy python wheels for torch and tensorflow so arm can install them properly
COPY arm_wheels/tensorflow-1.14.0-cp37-none-linux_aarch64.whl .
COPY arm_wheels/torch-1.4.0a0+7f73f1d-cp37-cp37m-linux_aarch64.whl .
### Install tensorflow
#RUN if [ "x$TARGETPLATFORM" = "xlinux/arm64" ] ; then pip install tensorflow-1.14.0-cp37-none-linux_aarch64.whl; rm tensorflow-1.14.0-cp37-none-linux_aarch64.whl; else pip install tensorflow==1.14.0; fi
### Install pytorch
RUN if [ "x$TARGETPLATFORM" = "xlinux/arm64" ] ; then pip install torch-1.4.0a0+7f73f1d-cp37-cp37m-linux_aarch64.whl; rm torch-1.4.0a0+7f73f1d-cp37-cp37m-linux_aarch64.whl; else pip install torch; fi

RUN python3 -m pip install --user -r requirements.txt