diff --git a/Dockerfile b/Dockerfile index bb85bbf..d2f2d70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,15 +13,20 @@ RUN python -m pip install -U pip && \ mkdir -p logs && \ touch -a logs/dlite_entities_service.log +## DEVELOPMENT target + FROM base as development ENV PORT=80 EXPOSE ${PORT} +# Set debug mode, since we're running in development mode ENV ENTITY_SERVICE_DEBUG=1 ENTRYPOINT uvicorn --host 0.0.0.0 --port ${PORT} --log-level debug --no-server-header --header "Server:DLiteEntitiesService" --reload dlite_entities_service.main:APP +## PRODUCTION target + FROM base as production RUN pip install -U --upgrade-strategy=eager -e .[production] @@ -29,6 +34,7 @@ RUN pip install -U --upgrade-strategy=eager -e .[production] ENV PORT=80 EXPOSE ${PORT} +# Force debug mode to be off, since we're running in production mode ENV ENTITY_SERVICE_DEBUG=0 ENTRYPOINT gunicorn --bind "0.0.0.0:${PORT}" --workers 1 --worker-class dlite_entities_service.uvicorn.UvicornWorker dlite_entities_service.main:APP diff --git a/dlite_entities_service/cli/_utils/global_settings.py b/dlite_entities_service/cli/_utils/global_settings.py index c2140e4..1091288 100644 --- a/dlite_entities_service/cli/_utils/global_settings.py +++ b/dlite_entities_service/cli/_utils/global_settings.py @@ -87,21 +87,10 @@ def global_options( CONTEXT["dotenv_path"] = dotenv_path if token: - access_token = Token(access_token=token) - - # I cannot come up with a scenario where this would not validate. + # I cannot come up with a scenario where the following line would not validate. # The only scenario in which it would happen is if `token` is not a string. # But it can never not be a string due to the way the input is parsed. - # Even the `if token:` sentence ensures that it will never be an empty string at - # that... - # However, should a case ever come up, the following lines should be the - # 'except' part of a 'try/except'-block for generating the `Token()`: - - # except ValidationError as exc: - # raise typer.BadParameter( - # f"Invalid token: {token}", - # param=token, - # param_hint="Token should be given as a string.", - # ) from exc + # Even the `if token:` line above ensures that it will never be an empty string. + access_token = Token(access_token=token) CONTEXT["token"] = access_token