From 408839a72c30138de60fec265b3eec95436b7de7 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 14:42:07 +0100 Subject: [PATCH 01/15] try publish images --- .github/workflows/publish-images.yml | 58 ++++++++++++++++++++++++ resources/images/self-hosted-gateway.svg | 58 ++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 .github/workflows/publish-images.yml create mode 100644 resources/images/self-hosted-gateway.svg diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml new file mode 100644 index 0000000..7610701 --- /dev/null +++ b/.github/workflows/publish-images.yml @@ -0,0 +1,58 @@ +name: Build Docker Images + +on: + # workflow_run: + # workflows: + # - Invariant gateway testing CI + # types: + # - completed + # branches: + # - main + # - v* + branches: + - ghcr + +jobs: + build-explorer-local-images: + runs-on: ubuntu-latest + # check that this is a tag or the 'main' branch but not a pull request + if: ${{ github.event.workflow_run.conclusion == 'success' && (github.ref_type == 'tag' || github.ref == 'refs/heads/main') }} + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + # based on whether this is a version tag or a branch, we will set the tags for the pushed images + - name: Set Docker Tags + id: set-tags + run: | + if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then + echo "tags=ghcr.io/${{ github.repository }}/app-api:latest" >> $GITHUB_ENV + echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest" >> $GITHUB_ENV + # starts with v* and only contains numbers and dots + elif [[ "${{ github.event.workflow_run.head_branch }}" =~ ^v[0-9.]+$ ]]; then + # get tag name from the event + version=${{ github.event.workflow_run.head_branch }} + # remove the refs/tags/ prefix + echo "version string is $version" + echo "tags=ghcr.io/${{ github.repository }}/app-api:latest,ghcr.io/${{ github.repository }}/app-api:${version}" >> $GITHUB_ENV + echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest,ghcr.io/${{ github.repository }}/app-ui:${version}" >> $GITHUB_ENV + else + echo "Failed to determine the tags for the Docker images for branch ${{ github.event.workflow_run.head_branch }}" + exit 1 + fi + + - name: Build app-api + uses: docker/build-push-action@v5 + with: + context: ./gateway + file: ./gateway/Dockerfile.gateway + platforms: linux/amd64 + push: true + tags: ${{ env.tags }} diff --git a/resources/images/self-hosted-gateway.svg b/resources/images/self-hosted-gateway.svg new file mode 100644 index 0000000..27e42f4 --- /dev/null +++ b/resources/images/self-hosted-gateway.svg @@ -0,0 +1,58 @@ + + + Group 13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From a34e88b9c7f2b161664c1f7aa8720d569b2cd8bc Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 14:42:48 +0100 Subject: [PATCH 02/15] fix trigger --- .github/workflows/publish-images.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 7610701..86ac1f5 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -9,8 +9,9 @@ on: # branches: # - main # - v* - branches: - - ghcr + push: + branches: + - ghcr jobs: build-explorer-local-images: From eb969c24df5918867e7f167182ea21f66b1ce8af Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 14:43:17 +0100 Subject: [PATCH 03/15] fix condition --- .github/workflows/publish-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 86ac1f5..47d5f49 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -17,7 +17,7 @@ jobs: build-explorer-local-images: runs-on: ubuntu-latest # check that this is a tag or the 'main' branch but not a pull request - if: ${{ github.event.workflow_run.conclusion == 'success' && (github.ref_type == 'tag' || github.ref == 'refs/heads/main') }} + if: ${{ github.event.workflow_run.conclusion == 'success' && (github.ref_type == 'tag' || github.ref == 'refs/heads/ghcr') }} steps: - name: Checkout Code From 68fbdc49a3498dcce20628f062e79680a6bb9ce6 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 14:43:37 +0100 Subject: [PATCH 04/15] fix trigger --- .github/workflows/publish-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 47d5f49..6035183 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -17,7 +17,7 @@ jobs: build-explorer-local-images: runs-on: ubuntu-latest # check that this is a tag or the 'main' branch but not a pull request - if: ${{ github.event.workflow_run.conclusion == 'success' && (github.ref_type == 'tag' || github.ref == 'refs/heads/ghcr') }} + # if: ${{ github.event.workflow_run.conclusion == 'success' && (github.ref_type == 'tag' || github.ref == 'refs/heads/main') }} steps: - name: Checkout Code From 2f8a019ae09880212cd4e5735b5b87109ca92062 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 14:44:24 +0100 Subject: [PATCH 05/15] testing tags --- .github/workflows/publish-images.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 6035183..0fc57ed 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -37,6 +37,10 @@ jobs: echo "tags=ghcr.io/${{ github.repository }}/app-api:latest" >> $GITHUB_ENV echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest" >> $GITHUB_ENV # starts with v* and only contains numbers and dots + if [[ "${{ github.event.workflow_run.head_branch }}" == "ghcr" ]]; then + echo "tags=ghcr.io/${{ github.repository }}/app-api:ghcr-testing" >> $GITHUB_ENV + echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:ghcr-testing" >> $GITHUB_ENV + # starts with v* and only contains numbers and dots elif [[ "${{ github.event.workflow_run.head_branch }}" =~ ^v[0-9.]+$ ]]; then # get tag name from the event version=${{ github.event.workflow_run.head_branch }} From 5ec6d3403ad58b9df707731b8fd6b9ce357bfe1a Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 14:45:33 +0100 Subject: [PATCH 06/15] testing tags --- .github/workflows/publish-images.yml | 38 +++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 0fc57ed..4e3421a 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -32,28 +32,26 @@ jobs: # based on whether this is a version tag or a branch, we will set the tags for the pushed images - name: Set Docker Tags id: set-tags + # run: | + # if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then + # echo "tags=ghcr.io/${{ github.repository }}/app-api:latest" >> $GITHUB_ENV + # echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest" >> $GITHUB_ENV + # # starts with v* and only contains numbers and dots + # elif [[ "${{ github.event.workflow_run.head_branch }}" =~ ^v[0-9.]+$ ]]; then + # # get tag name from the event + # version=${{ github.event.workflow_run.head_branch }} + # # remove the refs/tags/ prefix + # echo "version string is $version" + # echo "tags=ghcr.io/${{ github.repository }}/app-api:latest,ghcr.io/${{ github.repository }}/app-api:${version}" >> $GITHUB_ENV + # echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest,ghcr.io/${{ github.repository }}/app-ui:${version}" >> $GITHUB_ENV + # else + # echo "Failed to determine the tags for the Docker images for branch ${{ github.event.workflow_run.head_branch }}" + # exit 1 + # fi run: | - if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then - echo "tags=ghcr.io/${{ github.repository }}/app-api:latest" >> $GITHUB_ENV - echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest" >> $GITHUB_ENV - # starts with v* and only contains numbers and dots - if [[ "${{ github.event.workflow_run.head_branch }}" == "ghcr" ]]; then - echo "tags=ghcr.io/${{ github.repository }}/app-api:ghcr-testing" >> $GITHUB_ENV - echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:ghcr-testing" >> $GITHUB_ENV - # starts with v* and only contains numbers and dots - elif [[ "${{ github.event.workflow_run.head_branch }}" =~ ^v[0-9.]+$ ]]; then - # get tag name from the event - version=${{ github.event.workflow_run.head_branch }} - # remove the refs/tags/ prefix - echo "version string is $version" - echo "tags=ghcr.io/${{ github.repository }}/app-api:latest,ghcr.io/${{ github.repository }}/app-api:${version}" >> $GITHUB_ENV - echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest,ghcr.io/${{ github.repository }}/app-ui:${version}" >> $GITHUB_ENV - else - echo "Failed to determine the tags for the Docker images for branch ${{ github.event.workflow_run.head_branch }}" - exit 1 - fi + echo "tags=ghcr.io/${{ github.repository }}/gateway:ghcr-testing" >> $GITHUB_ENV - - name: Build app-api + - name: build gateway image uses: docker/build-push-action@v5 with: context: ./gateway From dc7d19d51068435dab098eeed52428de265daee4 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 15:08:05 +0100 Subject: [PATCH 07/15] signal handling --- gateway/Dockerfile.gateway | 4 +++- gateway/run.sh | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gateway/Dockerfile.gateway b/gateway/Dockerfile.gateway index 992aaad..431bfba 100644 --- a/gateway/Dockerfile.gateway +++ b/gateway/Dockerfile.gateway @@ -8,5 +8,7 @@ COPY . /srv/gateway # Ensure run.sh is executable RUN chmod +x /srv/gateway/run.sh +WORKDIR /srv/gateway -ENTRYPOINT ./run.sh \ No newline at end of file +# Run the application +CMD ["./run.sh"] \ No newline at end of file diff --git a/gateway/run.sh b/gateway/run.sh index 0663eea..fe6570a 100755 --- a/gateway/run.sh +++ b/gateway/run.sh @@ -9,8 +9,10 @@ if [ $? -ne 0 ]; then exit 1 fi +# using 'exec' belows ensures that signals like SIGTERM are passed to the child process +# and not the shell script itself (important when running in a container) if [ "$DEV_MODE" = "true" ]; then - uvicorn serve:app --host 0.0.0.0 --port 8000 --reload + exec uvicorn serve:app --host 0.0.0.0 --port 8000 --reload else - uvicorn serve:app --host 0.0.0.0 --port 8000 + exec uvicorn serve:app --host 0.0.0.0 --port 8000 fi \ No newline at end of file From e40ea3e2a9f205c2815b881b6afd2f391c1164ff Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:38:41 +0100 Subject: [PATCH 08/15] instructions + port configuration option --- README.md | 27 +++++++++++++++++++++++++-- gateway/.env | 4 ++++ gateway/common/config_manager.py | 2 +- gateway/run.sh | 7 +++++-- gateway/validate_config.py | 2 +- 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 gateway/.env diff --git a/README.md b/README.md index 36fd212..8816f52 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ To add Gateway to your agentic system, follow one of the integration guides belo ## **Integration Guides** ### **🔹 OpenAI Integration** + Gateway supports the OpenAI Chat Completions API (`/v1/chat/completions` endpoint). 1. Follow [these steps](https://platform.openai.com/docs/quickstart#create-and-export-an-api-key) to obtain an OpenAI API key. @@ -62,6 +63,7 @@ Gateway supports the OpenAI Chat Completions API (`/v1/chat/completions` endpoin > **Note:** Do not include the curly braces `{}`. If the dataset does not exist in Invariant Explorer, it will be created before adding traces. ### **🔹 Anthropic Integration** + Gateway supports the Anthropic Messages API (`/v1/messages` endpoint). 1. Follow [these steps](https://docs.anthropic.com/en/docs/initial-setup#set-your-api-key) to obtain an Anthropic API key. @@ -84,6 +86,7 @@ Gateway supports the Anthropic Messages API (`/v1/messages` endpoint). > **Note:** Do not include the curly braces `{}`. If the dataset does not exist in Invariant Explorer, it will be created before adding traces. ### **🔹 Gemini Integration** + Gateway supports the Gemini `generateContent` and `streamGenerateContent` methods. 1. Follow [these steps](https://ai.google.dev/gemini-api/docs/api-key) to obtain a Gemini API key. @@ -91,7 +94,7 @@ Gateway supports the Gemini `generateContent` and `streamGenerateContent` method ```python import os - + from google import genai client = genai.Client( @@ -249,14 +252,34 @@ This setup ensures that SWE-agent works seamlessly with Invariant Gateway, maint You can also operate your own instance of the Gateway, to ensure privacy and security. -First, clone this repository. To start the Invariant Gateway, run: +To run Gateway locally, you have two options: + +### 1. Run gateway from the repository + +1. Clone this repository. + +2. To start the Invariant Gateway, then run the following commands. Note that you need to have Docker installed. ```bash +cd invariant-gateway bash run.sh build && bash run.sh up ``` This will launch Gateway at [http://localhost:8005/api/v1/gateway/](http://localhost:8005/api/v1/gateway/docs/). +### 2. Run the Gateway using the published Docker image + +You can also run the Gateway using the published Docker image. This is a good option if you want to run the Gateway in a cloud environment. + +```bash +# pull the latest image +docker pull ghcr.io/invariantlabs-ai/invariant-gateway:latest +# run Gateway on localhost:8002 +docker run -p 8002:8002 -e PORT=8002 ghcr.io/invariantlabs-ai/invariant-gateway:latest +``` + +This will launch Gateway at [http://localhost:8002/api/v1/gateway/](http://localhost:8002/api/v1/gateway/docs/). + ### **Set Up an Invariant API Key** 1. Follow the instructions [here](https://explorer.invariantlabs.ai/docs/explorer/api/client-setup/) to obtain an API key. This allows the gateway to push traces to [Invariant Explorer](https://explorer.invariantlabs.ai). diff --git a/gateway/.env b/gateway/.env new file mode 100644 index 0000000..78d3391 --- /dev/null +++ b/gateway/.env @@ -0,0 +1,4 @@ +POSTGRES_USER=postgres + POSTGRES_PASSWORD=postgres + POSTGRES_DB=invariantmonitor + POSTGRES_HOST=database \ No newline at end of file diff --git a/gateway/common/config_manager.py b/gateway/common/config_manager.py index 09c5904..7bdb3e2 100644 --- a/gateway/common/config_manager.py +++ b/gateway/common/config_manager.py @@ -20,7 +20,7 @@ class GatewayConfig: policies_file = os.getenv("POLICIES_FILE_PATH", "") if not policies_file: - print("Warning: POLICIES_FILE_PATH is not set. Using empty policies.") + print("[warning: POLICIES_FILE_PATH is not set. Using empty policies]") return "" try: diff --git a/gateway/run.sh b/gateway/run.sh index fe6570a..ebc4b1b 100755 --- a/gateway/run.sh +++ b/gateway/run.sh @@ -9,10 +9,13 @@ if [ $? -ne 0 ]; then exit 1 fi +# check if PORT environment variable is set +UVICORN_PORT=${PORT:-8000} + # using 'exec' belows ensures that signals like SIGTERM are passed to the child process # and not the shell script itself (important when running in a container) if [ "$DEV_MODE" = "true" ]; then - exec uvicorn serve:app --host 0.0.0.0 --port 8000 --reload + exec uvicorn serve:app --host 0.0.0.0 --port $UVICORN_PORT --reload else - exec uvicorn serve:app --host 0.0.0.0 --port 8000 + exec uvicorn serve:app --host 0.0.0.0 --port $UVICORN_PORT fi \ No newline at end of file diff --git a/gateway/validate_config.py b/gateway/validate_config.py index 4d13c89..99a24bb 100644 --- a/gateway/validate_config.py +++ b/gateway/validate_config.py @@ -6,7 +6,7 @@ from common.config_manager import GatewayConfigManager try: _ = GatewayConfigManager.get_config() - print("GatewayConfig validated successfully.") + print("[gateway config validated successfully]") sys.exit(0) except Exception as e: print(f"Error loading GatewayConfig error: {e}") From 400870e0b553cce421addf507a8621fc79863ffb Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:41:04 +0100 Subject: [PATCH 09/15] update readme --- README.md | 4 +- resources/images/self-hosted-gateway.svg | 58 ------------------------ 2 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 resources/images/self-hosted-gateway.svg diff --git a/README.md b/README.md index 8816f52..9be0f66 100644 --- a/README.md +++ b/README.md @@ -274,8 +274,8 @@ You can also run the Gateway using the published Docker image. This is a good op ```bash # pull the latest image docker pull ghcr.io/invariantlabs-ai/invariant-gateway:latest -# run Gateway on localhost:8002 -docker run -p 8002:8002 -e PORT=8002 ghcr.io/invariantlabs-ai/invariant-gateway:latest +# run Gateway on localhost:8005 +docker run -p 8005:8005 -e PORT=8005 ghcr.io/invariantlabs-ai/invariant-gateway:latest ``` This will launch Gateway at [http://localhost:8002/api/v1/gateway/](http://localhost:8002/api/v1/gateway/docs/). diff --git a/resources/images/self-hosted-gateway.svg b/resources/images/self-hosted-gateway.svg deleted file mode 100644 index 27e42f4..0000000 --- a/resources/images/self-hosted-gateway.svg +++ /dev/null @@ -1,58 +0,0 @@ - - - Group 13 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 266ad2f3687e1937bc6bfcd1b846f7cf71a52b7e Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:41:50 +0100 Subject: [PATCH 10/15] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9be0f66..031961f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **LLM proxy to observe and debug what your AI agents are doing.** -[Documentation](https://explorer.invariantlabs.ai/docs/gateway) | [Quickstart for Users](#quickstart-for-users) | [Quickstart for Developers](#quickstart-for-developers) +[Documentation](https://explorer.invariantlabs.ai/docs/gateway) | [Quickstart for Users](#quickstart-for-users) | [Quickstart for Developers](#quickstart-for-developers) | [Run Locally](#run-the-gateway-locally) From 9205538f60ae3bf6b59105a8fb4cfece24d6e1c5 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:43:20 +0100 Subject: [PATCH 11/15] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 031961f..c5937bd 100644 --- a/README.md +++ b/README.md @@ -273,9 +273,9 @@ You can also run the Gateway using the published Docker image. This is a good op ```bash # pull the latest image -docker pull ghcr.io/invariantlabs-ai/invariant-gateway:latest +docker pull --platform linux/amd64 ghcr.io/invariantlabs-ai/invariant-gateway:latest # run Gateway on localhost:8005 -docker run -p 8005:8005 -e PORT=8005 ghcr.io/invariantlabs-ai/invariant-gateway:latest +docker run -p 8005:8005 -e PORT=8005 --platform linux/amd64 ghcr.io/invariantlabs-ai/invariant-gateway/gateway:latest ``` This will launch Gateway at [http://localhost:8002/api/v1/gateway/](http://localhost:8002/api/v1/gateway/docs/). From d47cfef51c25ca5b148b99216ad3a9f5a7b205ad Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:44:35 +0100 Subject: [PATCH 12/15] root redirect --- gateway/serve.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gateway/serve.py b/gateway/serve.py index 5fcdf16..e3683f9 100644 --- a/gateway/serve.py +++ b/gateway/serve.py @@ -32,5 +32,14 @@ router.include_router(gemini_gateway, prefix="/gateway", tags=["gemini_gateway"] app.include_router(router) +# on / redirect to https://explorer.invariantlabs.ai/docs/gateway +@app.get("/", include_in_schema=False) +async def redirect_to_explorer(): + """Redirect to the explorer""" + return fastapi.responses.RedirectResponse( + url="https://explorer.invariantlabs.ai/docs/gateway" + ) + + if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8000) From 8709ff4bd8463a5ea1a6d0eb3d9ec0b24ab68ec3 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:47:53 +0100 Subject: [PATCH 13/15] enable CI --- .github/workflows/publish-images.yml | 49 +++++++++++++--------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index 4e3421a..c160b34 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -1,17 +1,14 @@ name: Build Docker Images on: - # workflow_run: - # workflows: - # - Invariant gateway testing CI - # types: - # - completed - # branches: - # - main - # - v* - push: + workflow_run: + workflows: + - Invariant gateway testing CI + types: + - completed branches: - - ghcr + - main + - v* jobs: build-explorer-local-images: @@ -32,24 +29,22 @@ jobs: # based on whether this is a version tag or a branch, we will set the tags for the pushed images - name: Set Docker Tags id: set-tags - # run: | - # if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then - # echo "tags=ghcr.io/${{ github.repository }}/app-api:latest" >> $GITHUB_ENV - # echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest" >> $GITHUB_ENV - # # starts with v* and only contains numbers and dots - # elif [[ "${{ github.event.workflow_run.head_branch }}" =~ ^v[0-9.]+$ ]]; then - # # get tag name from the event - # version=${{ github.event.workflow_run.head_branch }} - # # remove the refs/tags/ prefix - # echo "version string is $version" - # echo "tags=ghcr.io/${{ github.repository }}/app-api:latest,ghcr.io/${{ github.repository }}/app-api:${version}" >> $GITHUB_ENV - # echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest,ghcr.io/${{ github.repository }}/app-ui:${version}" >> $GITHUB_ENV - # else - # echo "Failed to determine the tags for the Docker images for branch ${{ github.event.workflow_run.head_branch }}" - # exit 1 - # fi run: | - echo "tags=ghcr.io/${{ github.repository }}/gateway:ghcr-testing" >> $GITHUB_ENV + if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then + echo "tags=ghcr.io/${{ github.repository }}/app-api:latest" >> $GITHUB_ENV + echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest" >> $GITHUB_ENV + # starts with v* and only contains numbers and dots + elif [[ "${{ github.event.workflow_run.head_branch }}" =~ ^v[0-9.]+$ ]]; then + # get tag name from the event + version=${{ github.event.workflow_run.head_branch }} + # remove the refs/tags/ prefix + echo "version string is $version" + echo "tags=ghcr.io/${{ github.repository }}/app-api:latest,ghcr.io/${{ github.repository }}/app-api:${version}" >> $GITHUB_ENV + echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest,ghcr.io/${{ github.repository }}/app-ui:${version}" >> $GITHUB_ENV + else + echo "Failed to determine the tags for the Docker images for branch ${{ github.event.workflow_run.head_branch }}" + exit 1 + fi - name: build gateway image uses: docker/build-push-action@v5 From ee013de105cd065de50a363dcba571f614d75d3f Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:48:29 +0100 Subject: [PATCH 14/15] fig tags in CI --- .github/workflows/publish-images.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml index c160b34..04e8fb9 100644 --- a/.github/workflows/publish-images.yml +++ b/.github/workflows/publish-images.yml @@ -31,16 +31,14 @@ jobs: id: set-tags run: | if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then - echo "tags=ghcr.io/${{ github.repository }}/app-api:latest" >> $GITHUB_ENV - echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest" >> $GITHUB_ENV + echo "tags=ghcr.io/${{ github.repository }}/gateway:latest" >> $GITHUB_ENV # starts with v* and only contains numbers and dots elif [[ "${{ github.event.workflow_run.head_branch }}" =~ ^v[0-9.]+$ ]]; then # get tag name from the event version=${{ github.event.workflow_run.head_branch }} # remove the refs/tags/ prefix echo "version string is $version" - echo "tags=ghcr.io/${{ github.repository }}/app-api:latest,ghcr.io/${{ github.repository }}/app-api:${version}" >> $GITHUB_ENV - echo "tags_ui=ghcr.io/${{ github.repository }}/app-ui:latest,ghcr.io/${{ github.repository }}/app-ui:${version}" >> $GITHUB_ENV + echo "tags=ghcr.io/${{ github.repository }}/gateway:latest,ghcr.io/${{ github.repository }}/gateway:${version}" >> $GITHUB_ENV else echo "Failed to determine the tags for the Docker images for branch ${{ github.event.workflow_run.head_branch }}" exit 1 From c5d9f075a43a6e23f5da54a6a61de5b401d06a2e Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Tue, 11 Mar 2025 17:51:50 +0100 Subject: [PATCH 15/15] update image names --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5937bd..cf80126 100644 --- a/README.md +++ b/README.md @@ -273,7 +273,7 @@ You can also run the Gateway using the published Docker image. This is a good op ```bash # pull the latest image -docker pull --platform linux/amd64 ghcr.io/invariantlabs-ai/invariant-gateway:latest +docker pull --platform linux/amd64 ghcr.io/invariantlabs-ai/invariant-gateway/gateway:latest # run Gateway on localhost:8005 docker run -p 8005:8005 -e PORT=8005 --platform linux/amd64 ghcr.io/invariantlabs-ai/invariant-gateway/gateway:latest ```