diff --git a/Dockerfile b/Dockerfile index 02fd29cb..86a2b097 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,20 @@ FROM ghcr.io/cfpb/regtech/sbl/python-alpine:3.12 +ENV UVICORN_LOG_LEVEL=info + WORKDIR /usr/app -RUN mkdir reports +RUN mkdir upload RUN pip install poetry -COPY poetry.lock pyproject.toml alembic.ini README.md ./ - -COPY ./src ./src -COPY ./db_revisions ./db_revisions +COPY --chown=sbl:sbl poetry.lock pyproject.toml alembic.ini README.md ./ RUN poetry config virtualenvs.create false -RUN poetry install --only main +RUN poetry install --only main --no-root + +COPY --chown=sbl:sbl ./src ./src +COPY --chown=sbl:sbl ./db_revisions ./db_revisions + +RUN chmod -R 447 /usr/app/upload WORKDIR /usr/app/src @@ -18,4 +22,4 @@ EXPOSE 8888 USER sbl -CMD ["python", "sbl_filing_api/main.py"] +CMD uvicorn sbl_filing_api.main:app --host 0.0.0.0 --port 8888 --log-config log-config.yml --log-level $UVICORN_LOG_LEVEL --timeout-keep-alive 65 diff --git a/src/sbl_filing_api/main.py b/src/sbl_filing_api/main.py index 74d95531..8a2a2fed 100644 --- a/src/sbl_filing_api/main.py +++ b/src/sbl_filing_api/main.py @@ -1,6 +1,5 @@ import logging import os -import uvicorn from contextlib import asynccontextmanager @@ -26,7 +25,7 @@ from alembic.config import Config from alembic import command -from sbl_filing_api.config import settings, kc_settings +from sbl_filing_api.config import kc_settings log = logging.getLogger() @@ -72,15 +71,3 @@ def run_migrations(): app.include_router(filing_router, prefix="/v1/filing") - - -if __name__ == "__main__": - uvicorn.run( - "sbl_filing_api.main:app", - host=settings.server_config.host, - port=settings.server_config.port, - timeout_keep_alive=settings.server_config.time_out, - workers=settings.server_config.workers, - reload=settings.server_config.reload, - log_config=settings.server_config.log_config, - )