-
Notifications
You must be signed in to change notification settings - Fork 17
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
add build push docker image image in the publish ci #311
Conversation
PR is not ready yet ... I will ping you when it's ready |
it's done from my side ping @jonhealy1 and @jamesfisher-geo it's ready for code review. also if it;s possible please take a test on the produced images to ensure workflow works fine, thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice work here! If @jamesfisher-geo @rhysrevans3 @pedro-cf and/or @StijnCaerts have the time to take a look as well it would be really helpful. Thank you.
Hey @mo-dkrz great work and thanks for the contribution. I have a couple questions/comments Could you make it clear in the readme which .env parameters are required and which are optional? There is an issue where default values being set to empty strings if they are not defined in the .env file. For example, If I run without File "/usr/local/lib/python3.11/dist-packages/uvicorn/config.py", line 365, in __init__
self.workers = int(os.environ["WEB_CONCURRENCY"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '' If I run without setting File "/usr/local/lib/python3.11/dist-packages/stac_fastapi/elasticsearch/app.py", line 5, in <module>
from stac_fastapi.api.app import StacApi
File "/usr/local/lib/python3.11/dist-packages/stac_fastapi/api/app.py", line 31, in <module>
from stac_fastapi.types.core import AsyncBaseCoreClient, BaseCoreClient
File "/usr/local/lib/python3.11/dist-packages/stac_fastapi/types/core.py", line 37, in <module>
api_settings = ApiSettings()
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pydantic_settings/main.py", line 167, in __init__
super().__init__(
File "/usr/local/lib/python3.11/dist-packages/pydantic/main.py", line 212, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ApiSettings
reload
Input should be a valid boolean, unable to interpret input [type=bool_parsing, input_value='', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/bool_parsing |
Generally I am curious if it is best practice to separate the backend (elasticsearch or opensearch) containers from the stac-fastapi-es and stac-fastapi-os. So the published containers are the STAC API service only @jonhealy1 @StijnCaerts @pedro-cf @rhysrevans3 |
dockerfiles/Dockerfile.ci.es
Outdated
@@ -0,0 +1,75 @@ | |||
FROM debian:bookworm-slim AS base | |||
|
|||
ARG STAC_FASTAPI_TITLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is setting all values not specified in the .env
file to empty strings. Could you modify to handle default values?
dockerfiles/Dockerfile.ci.os
Outdated
@@ -0,0 +1,75 @@ | |||
FROM debian:bookworm-slim AS base | |||
|
|||
ARG STAC_FASTAPI_TITLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is setting all values not specified in the .env
file to empty strings. Could you modify to handle default values?
README.md
Outdated
|
||
You need to provide a `.env` file to configure the environment variables. Here's a list of variables you can configure: | ||
|
||
- `STAC_FASTAPI_TITLE`: Title of the API shown in the documentation (default: `stac-fastapi-elasticsearch` or `stac-fastapi-opensearch`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make it clear which parameters are required?
… files since they already got defualt vals
Good point! Let’s tidy up the environment variables. It seems that Done! pipeline got green, so I’ve updated the Dockerfiles and README accordingly. @jamesfisher-geo could you please take a smoke test with/without defining any env var and review again the README as well? thanks |
It’s also a good idea to have all search engines in the same environment, allowing users to enable or disable a specific search engine via environment variables, such as |
@jamesfisher-geo @mo-dkrz I think James is right and the database service should be separated from the api. The stac-fastapi-elasticsearch instance for example should be able to connect to an elasticsearch instance/ cluster running anywhere. Many people will be running the api container and the database on different specialised services. |
ähm, based on my experience, I think providing backends in a container as an optional tool offer more flexibility to users and increases its appeal due to ease of configuration and maintenance. For instance, by defining |
I think |
@mo-dkrz having the option to turn the database in the container on or off is interesting. It would have to be well documented |
Using docker compose is useful for development I think. The ghcr containers are useful for deployment but not for reflecting local changes to the api during development, unless I'm missing something here? |
…ainer and updated readme
@jonhealy1 I tried to document it better in README. could you please review it again? And also docker-compose is still working as the first method ... |
Thanks for the quick responses @mo-dkrz I would like to suggest a change in the approach here. For developing the API locally, it is the best-practice to clone the repo and run
or
Either of these will create two local Docker images, the respective backend and the STAC API, which you can use to build new features. Published packages are generally for production use-cases. So users would pull the images of a release and deploy that to their infrastructure, pointing to their instance of elasticsearch/opensearch. It is not useful to include elasticsearch/opensearch in the same published image as the STAC API, at least not in the published images for our main branch here because:
The publishing steps you have are a great contribution. Would you be open to contributing the work to publish the stac-fastapi-es and stac-fastapi-os images without the backends? |
Thanks @jamesfisher-geo for the review; on the weekend I will be back to dismantle the backend from image |
Thanks so much! |
I think it's done; I removed the backend from the images and reflected the changes on README and action as well. btw I reflected the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @mo-dkrz , a few more changes needed here. Thanks
###### Key variables to configure: | ||
|
||
| Variable | Description | Default | Required | | ||
|------------------------------|--------------------------------------------------------------------------------------|--------------------------|---------------------------------------------------------------------------------------------| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great
docker-compose.yml
Outdated
@@ -3,11 +3,8 @@ version: '3.9' | |||
services: | |||
app-elasticsearch: | |||
container_name: stac-fastapi-es | |||
image: stac-utils/stac-fastapi-es | |||
image: ghcr.io/stac-utils/stac-fastapi-es:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this to pulling from the local code like it was doing before (stac-utils/stac-fastapi-es
)? The docker-compose file is used for local development, so we want it to build an image from the local code.
docker-compose.yml
Outdated
restart: always | ||
build: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this back to use the local Dockerfile.dev.es
docker-compose.yml
Outdated
@@ -35,11 +32,8 @@ services: | |||
|
|||
app-opensearch: | |||
container_name: stac-fastapi-os | |||
image: stac-utils/stac-fastapi-os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this to pulling from the local code like it was doing before (stac-utils/stac-fastapi-os
)? The docker-compose file is used for local development, so we want it to build an image from the local code.
docker-compose.yml
Outdated
restart: always | ||
build: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this back to use the local Dockerfile.dev.os
dockerfiles/Dockerfile.ci.es
Outdated
@@ -0,0 +1,34 @@ | |||
FROM python:3.12-slim | |||
|
|||
ENV APP_HOST="0.0.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but could you remove the ENV lines here? The environment variables should be set when you run the Docker image. Either from an ,env file or as -e
tags in the docker run
command. They don't need to be included in the Dockerfile.
dockerfiles/Dockerfile.ci.os
Outdated
@@ -0,0 +1,34 @@ | |||
FROM python:3.12-slim | |||
|
|||
ENV STAC_FASTAPI_TITLE="stac-fastapi-opensearch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but could you remove the ENV lines here? The environment variables should be set when you run the Docker image. Either from an ,env file or as -e
tags in the docker run
command. They don't need to be included in the Dockerfile.
@jamesfisher-geo I'v updated the change reqs, could you please review it again, thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks @mo-dkrz!
Thanks for the hard work here @mo-dkrz @jamesfisher-geo. The only thing I think we may be missing is some documentation explaining how to use these new docker images. |
I made a bit of docs in README about installing and running via pre-built docker imgs, but I think it's not regular to add images docs in REAME since we have them in the pkg registry container of github and when each user needs the imgs, they pull them from there. Could you have a look and review it again @jamesfisher-geo @jonhealy1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @mo-dkrz thank you
Quite a few errors with the tests
|
same errors in main branch now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are failing because httpx used in tests just released a new version.
Related Issue(s):
Description:
Since I needed to have this docker images of elastic search and open search, I added a new publish docker image step in publish.yml
ping @jonhealy1
PR Checklist:
pre-commit run --all-files
)make test
)