Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set root-path from uvicorn #221

Merged
merged 2 commits into from
Jun 14, 2024
Merged

Set root-path from uvicorn #221

merged 2 commits into from
Jun 14, 2024

Conversation

mmcfarland
Copy link
Member

@mmcfarland mmcfarland commented Jun 14, 2024

Description

Sets the root path in uvicorn to match that set via FastAPI. This is required with updates to starlette, which were included previously.

Fixes microsoft/PlanetaryComputer#360

Also updates the tests to more closely match the FastAPI setup (including the use of root_path) as well as ensures that the dev dependencies are equivalent to those in the running container.

Sets the root path in uvicorn to match that set via FastAPI. This is
required with updates to starlette, which were included previously.

Fixes microsoft/PlanetaryComputer#360
@@ -16,7 +16,7 @@ services:
- azurite
- redis
command: >
bash -c "pypgstac pgready && uvicorn pcstac.main:app --host 0.0.0.0 --port 8081 --reload --proxy-headers"
bash -c "pypgstac pgready && uvicorn pcstac.main:app --host 0.0.0.0 --port 8081 --reload --proxy-headers --root-path '/stac'"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally, this is the actual fix to the issue.

# is typically set via the APP_ROOT_PATH environment variable.
ENV APP_ROOT_PATH=""

CMD uvicorn pcstac.main:app --host ${APP_HOST} --port ${APP_PORT} --root-path ${APP_ROOT_PATH} --log-level info
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this fixes the issue in the deployed environment. APP_ROOT_PATH is already set in the Helm chart.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming the behavior here: The "default" APP_ROOT_PATH is set to "", but if the Helm chart defines it it'll override that?

And is the default of "" is correct? Not "/"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, I didn't want to give it a default value. Locally and on PCT, it's /stac and in PC its /api/stac/v1. The value is always set by either docker-compose or helm. I believe you need to declare the ENV in order for it be available when the container is run.

RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,source=requirements-dev.txt,target=requirements-dev.txt \
pip install -r requirements-dev.txt

RUN --mount=type=cache,target=/root/.cache \
pip install -e ./pccommon[dev] -e ./pcstac
pip install --no-deps -e ./pccommon[dev] -e ./pcstac
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensures that pcstac dependencies aren't overwritten by pccommon

flake8==3.8.4
isort==5.9.2
mypy==1.8.0
openapi-spec-validator==0.3.0
cachetools<=4.2.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a dev dependency and conflicted with installed dependencies on server images.

@mmcfarland mmcfarland merged commit 3b1e9f7 into main Jun 14, 2024
5 checks passed
@mmcfarland mmcfarland deleted the user/mjm/request-url-path branch June 14, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Items paging links broken
2 participants