content: FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10
  
  # Configure Poetry
  ENV POETRY_VERSION=1.2.0
  ENV POETRY_HOME=/opt/poetry
  ENV POETRY_VENV=/opt/poetry-venv
  ENV POETRY_CACHE_DIR=/opt/.cache
  
  # Install poetry separated from system interpreter
  RUN python3 -m venv $POETRY_VENV \
      && $POETRY_VENV/bin/pip install -U pip setuptools \
      && $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}
  
  # Add `poetry` to PATH
  ENV PATH="${PATH}:${POETRY_VENV}/bin"
  
  WORKDIR /app/
  
  # Copy poetry.lock* in case it doesn't exist in the repo
  COPY ./app/pyproject.toml ./app/poetry.lock* /app/
  
  # Allow installing dev dependencies to run tests
  ARG INSTALL_DEV=false
  RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
  
  # For development, Jupyter remote kernel, Hydrogen
  # Using inside the container:
  # jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888
  ARG INSTALL_JUPYTER=false
  RUN bash -c "if [ $INSTALL_JUPYTER == 'true' ] ; then pip install jupyterlab ; fi"
  
  # Install java, for Okapi
  RUN apt-get update
  RUN apt-get -y install default-jre
  
  # Local python package
  COPY ./src /tmp/src
  RUN pip install -e /tmp/src/.
  
  RUN chmod -R +x /tmp/src/okapi_segmentation # To fix permission error
  
  COPY app/app /app/app
  ENV PYTHONPATH=/app