# Use an official Python runtime as the base image
FROM python:3.10

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file to the working directory
COPY app/requirements.txt . 

# Copy the Tab-Lib dependencies to the working directory
COPY app/Tab-Lib-deps/ta-lib-0.4.0-src.tar.gz .

# Extract and install Tab-Lib
RUN tar -xzf ta-lib-0.4.0-src.tar.gz && \
    rm ta-lib-0.4.0-src.tar.gz && \
    cd ta-lib && \
    ./configure --prefix=/usr && \
    make && \
    make install && \
    cd ..

# Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install ejtraderMT -U

# Copy the application code to the container
COPY app/ .

# Run the bot script using xvfb-run
CMD [ "python", "bot.py" ]
