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

[Enhancement]: Allow template docker url to be modified via env #2075

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions agenta-backend/agenta_backend/services/templates_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
templates_base_url = os.getenv("TEMPLATES_BASE_URL")
agenta_template_repo = os.getenv("AGENTA_TEMPLATE_REPO")
docker_hub_url = os.getenv("DOCKER_HUB_URL")
docker_hub_template_url = os.getenv(
"DOCKER_HUB_TEMPLATE_URL", f"{docker_hub_url}/{{}}/tags"
)


async def update_and_sync_templates(cache: bool = True) -> None:
Expand Down Expand Up @@ -86,7 +89,7 @@ async def retrieve_templates_from_dockerhub_cached(cache: bool) -> List[dict]:

# If not cached, fetch data from Docker Hub and cache it in Redis
response = await retrieve_templates_from_dockerhub(
docker_hub_url,
docker_hub_template_url,
agenta_template_repo,
)
response_data = response["results"]
Expand Down Expand Up @@ -133,16 +136,16 @@ async def retrieve_templates_from_dockerhub(

Args:
url (str): The URL endpoint for retrieving templates. Should contain placeholders `{}`
for the `repo_owner` and `repo_name` values to be inserted. For example:
`https://hub.docker.com/v2/repositories/{}/{}/tags`.
for `repo_name` values to be inserted. For example:
`https://hub.docker.com/v2/repositories/{}/tags`.
repo_name (str): The name of the repository where the templates are located.

Returns:
tuple: A tuple containing two values.
"""

async with httpx.AsyncClient() as client:
response = await client.get(f"{url}/{repo_name}/tags", timeout=90)
response = await client.get(url.format(repo_name), timeout=90)
if response.status_code == 200:
response_data = response.json()
return response_data
Expand Down
1 change: 1 addition & 0 deletions docker-compose.gh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
- DOCKER_HUB_TEMPLATE_URL=https://hub.docker.com/v2/repositories/{}/tags
command:
[
"uvicorn",
Expand Down
1 change: 1 addition & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
- DOCKER_HUB_TEMPLATE_URL=https://hub.docker.com/v2/repositories/{}/tags
volumes:
- ./agenta-backend/agenta_backend:/app/agenta_backend
- ./agenta-backend/migrations:/app/migrations
Expand Down
1 change: 1 addition & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
- DOCKER_HUB_TEMPLATE_URL=https://hub.docker.com/v2/repositories/{}/tags
volumes:
- ./agenta-backend/agenta_backend:/app/agenta_backend
- ./agenta-backend/migrations:/app/migrations
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
- DOCKER_HUB_TEMPLATE_URL=https://hub.docker.com/v2/repositories/{}/tags
volumes:
- ./agenta-backend/agenta_backend:/app/agenta_backend
- ./agenta-backend/migrations:/app/migrations
Expand Down
Loading