# Use an official Python runtime as a parent image
ARG PYTHON_VERSION=3.12.5-slim
FROM python:${PYTHON_VERSION}

# Set environment variables to prevent Python from writing pyc files to disc and buffer output
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

# Create app directory
WORKDIR /app

#RUN apt-get update && apt-get install --no-install-recommends -y gcc g++
RUN POETRY_HOME=/opt/poetry && python3 -m venv $POETRY_HOME && $POETRY_HOME/bin/pip install poetry

EXPOSE 8501

# Bundle app source
COPY . /app

RUN /opt/poetry/bin/poetry install

COPY streamlit_cmd.sh /streamlit_cmd.sh
RUN chmod +x /streamlit_cmd.sh

CMD ["bash", "-x", "/streamlit_cmd.sh"]
