diff --git a/backend/Dockerfile b/backend/Dockerfile index d7a8db8b7..58171f1fb 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -29,7 +29,7 @@ RUN apt-get update -y && \ # copy project requirement files here to ensure they will be cached. WORKDIR $PYSETUP_PATH -COPY . /opt/monarch-app +COPY . /opt/monarch-app/backend # install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally RUN curl -sSL https://install.python-poetry.org | python3 && \ @@ -41,12 +41,12 @@ RUN curl -sSL https://install.python-poetry.org | python3 && \ FROM builder-base as production ENV SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True -ENV UVICORN_WORKERS=8 +# ENV UVICORN_WORKERS=8 WORKDIR /opt/monarch-app/backend RUN poetry install -CMD ["/opt/poetry/bin/poetry", "run", "uvicorn", "src.monarch_py.api.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "${UVICORN_WORKERS}"] +CMD /opt/monarch-app/backend/start_api.sh ### Image URLs for reference ### # diff --git a/backend/start_api.sh b/backend/start_api.sh new file mode 100755 index 000000000..d462f5b38 --- /dev/null +++ b/backend/start_api.sh @@ -0,0 +1,7 @@ +#!/usr/bin/bash + +# check for uvicorn workers env var, default to 1 +UVICORN_WORKERS=${UVICORN_WORKERS:-1} + +# Start the API +/opt/poetry/bin/poetry run uvicorn src.monarch_py.api.main:app --host 0.0.0.0 --port 8000 --workers ${UVICORN_WORKERS}