FROM python:3.11

ARG ENV=dev
ENV PATH="/root/.local/share/pypoetry:/root/.local/bin:${PATH}"

# Install tools
RUN curl -sSL https://install.python-poetry.org | python -
RUN poetry config virtualenvs.create false

# Install dependencies
COPY /pyproject.toml ./
RUN /bin/bash -c 'if [[ "${ENV}" == "production" ]] ; then poetry install --no-dev ; else poetry install ; fi'

WORKDIR /app

VOLUME ["/app"]

# Copy source code
#COPY /main.py ./

# As soon as App runs behind a proxy add: --proxy-headers
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
