From 46d762c38f45299ed03c44b6c32a650d5be11cbc Mon Sep 17 00:00:00 2001 From: Bernhard Froemel Date: Thu, 13 Feb 2025 11:29:44 +0100 Subject: [PATCH 1/4] Run CodeGate on remote host --- docs/about/faq.md | 45 ++++++++++++++++++++++++++++++++++++++++++ docs/how-to/install.md | 5 +++++ 2 files changed, 50 insertions(+) diff --git a/docs/about/faq.md b/docs/about/faq.md index 5e0bccb..a8c1c11 100644 --- a/docs/about/faq.md +++ b/docs/about/faq.md @@ -15,3 +15,48 @@ your client and the LLM it's communicating with. We are actively exploring additional integrations based on user feedback. [Join the community on Discord](https://discord.gg/stacklok) to let us know about your favorite AI coding tool! + +### How can I run CodeGate on a remote host? + +Currently, CodeGate is intended as a single-user system and to be run on and +accessed from a local (desktop) workstation system. Hence the CodeGate web +dashboard provided in the Docker container requires the CodeGate API to be +available on _localhost_. + +To run CodeGate on a remote host you need to build your own appropriately +customized Docker container image from the CodeGate GitHub repository. Use the +following steps as a reference and adjust them for your own setup: + +1. Clone the CodeGate GitHub repository: + + ```shell + git clone https://github.com/stacklok/codegate.git + cd codegate + ``` + +2. Edit `./Dockerfile` by adding (replace `` with the domain name + or IP address of the remote host which should provide CodeGate): + + ```Dockerfile + ENV VITE_BASE_API_URL=http://:8989 + ``` + + before the CodeGate web dashboard is built: + + ```Dockerfile + # Install the webapp dependencies and build it + RUN npm install + RUN npm run build + ``` + +3. Build the customized Docker image on the remote host: + + ```shell + make image-build + ``` + +4. Run the customized locally built Docker image: + + ```shell + docker run --name codegate -p 8989:8989 -p 9090:9090 codegate:latest + ``` diff --git a/docs/how-to/install.md b/docs/how-to/install.md index 3b67e51..719788b 100644 --- a/docs/how-to/install.md +++ b/docs/how-to/install.md @@ -16,6 +16,11 @@ replace `docker` with `podman` in all commands. ## Run CodeGate +By default the CodeGate Docker container expects to be run on and be accessed +from _localhost_. In case you want to deploy CodeGate on a remote host, follow +the instructions given +[here](../about/faq.md#how-can-i-run-codegate-on-a-remote-host). + ### Recommended settings To download and run CodeGate with the recommended configuration for full From d472fbbc2fbb69e3458ed360023c1e09a556dd76 Mon Sep 17 00:00:00 2001 From: Bernhard Froemel Date: Fri, 14 Feb 2025 09:47:12 +0100 Subject: [PATCH 2/4] restructuring, minor improvements --- docs/about/faq.md | 45 ---------------------------------- docs/how-to/configure.md | 52 ++++++++++++++++++++++++++++++++++++++++ docs/how-to/install.md | 13 ++++++---- 3 files changed, 61 insertions(+), 49 deletions(-) diff --git a/docs/about/faq.md b/docs/about/faq.md index a8c1c11..5e0bccb 100644 --- a/docs/about/faq.md +++ b/docs/about/faq.md @@ -15,48 +15,3 @@ your client and the LLM it's communicating with. We are actively exploring additional integrations based on user feedback. [Join the community on Discord](https://discord.gg/stacklok) to let us know about your favorite AI coding tool! - -### How can I run CodeGate on a remote host? - -Currently, CodeGate is intended as a single-user system and to be run on and -accessed from a local (desktop) workstation system. Hence the CodeGate web -dashboard provided in the Docker container requires the CodeGate API to be -available on _localhost_. - -To run CodeGate on a remote host you need to build your own appropriately -customized Docker container image from the CodeGate GitHub repository. Use the -following steps as a reference and adjust them for your own setup: - -1. Clone the CodeGate GitHub repository: - - ```shell - git clone https://github.com/stacklok/codegate.git - cd codegate - ``` - -2. Edit `./Dockerfile` by adding (replace `` with the domain name - or IP address of the remote host which should provide CodeGate): - - ```Dockerfile - ENV VITE_BASE_API_URL=http://:8989 - ``` - - before the CodeGate web dashboard is built: - - ```Dockerfile - # Install the webapp dependencies and build it - RUN npm install - RUN npm run build - ``` - -3. Build the customized Docker image on the remote host: - - ```shell - make image-build - ``` - -4. Run the customized locally built Docker image: - - ```shell - docker run --name codegate -p 8989:8989 -p 9090:9090 codegate:latest - ``` diff --git a/docs/how-to/configure.md b/docs/how-to/configure.md index 809e2f8..6bcf874 100644 --- a/docs/how-to/configure.md +++ b/docs/how-to/configure.md @@ -42,3 +42,55 @@ docker run --name codegate -d -p 8989:8989 -p 9090:9090 \ --mount type=volume,src=codegate_volume,dst=/app/codegate_volume \ --restart unless-stopped ghcr.io/stacklok/codegate ``` + +## Run CodeGate on a remote host + +:::warning + +Keep security aspects in mind and run CodeGate only on a remote host within a +local or otherwise secured network. CodeGate should not be run on a remote host +that is directly accessible from the Internet! + +::: + +The CodeGate web dashboard provided in the Docker container expects the CodeGate +API to be available on _localhost_ port 8989. Currently this is statically set +during build time and cannot be changed with a runtime configuration parameter. + +Hence to run CodeGate on a remote host you need to build your own appropriately +customized Docker container image from the CodeGate GitHub repository. Use the +following steps as a reference and adjust them for your own setup: + +1. Clone the CodeGate GitHub repository: + + ```shell + git clone https://github.com/stacklok/codegate.git + cd codegate + ``` + +2. Edit `./Dockerfile` by adding (replace `` with the domain name + or IP address of the remote host which should provide CodeGate): + + ```Dockerfile + ENV VITE_BASE_API_URL=http://:8989 + ``` + + before the CodeGate web dashboard is built: + + ```Dockerfile + # Install the webapp dependencies and build it + RUN npm install + RUN npm run build + ``` + +3. Build the customized Docker image on the remote host: + + ```shell + make image-build + ``` + +4. Run the customized locally built Docker image: + + ```shell + docker run --name codegate -p 8989:8989 -p 9090:9090 codegate:latest + ``` diff --git a/docs/how-to/install.md b/docs/how-to/install.md index 719788b..89f7be2 100644 --- a/docs/how-to/install.md +++ b/docs/how-to/install.md @@ -16,10 +16,15 @@ replace `docker` with `podman` in all commands. ## Run CodeGate -By default the CodeGate Docker container expects to be run on and be accessed -from _localhost_. In case you want to deploy CodeGate on a remote host, follow -the instructions given -[here](../about/faq.md#how-can-i-run-codegate-on-a-remote-host). +CodeGate is primarily intended as a single-user system. There is no +authentication when using the CodeGate API or the CodeGate web dashboard which +are both operating over unencrypted HTTP. Hence all CodeGate components are +supposed to bind to _localhost_ (`127.0.0.1`) and remain inaccessible from +remote hosts. + +If you are an advanced user who wants to run CodeGate on a remote host in a +secured/local network, consider the information given +[here](./configure.md#run-codegate-on-a-remote-host). ### Recommended settings From 4722e000ba4bb02968b45a10784cf02dfb8a55f3 Mon Sep 17 00:00:00 2001 From: Bernhard Froemel Date: Fri, 14 Feb 2025 19:23:02 +0100 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Dan Barr --- docs/how-to/configure.md | 21 +++++++++++---------- docs/how-to/install.md | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/how-to/configure.md b/docs/how-to/configure.md index 6bcf874..630a883 100644 --- a/docs/how-to/configure.md +++ b/docs/how-to/configure.md @@ -68,29 +68,30 @@ following steps as a reference and adjust them for your own setup: cd codegate ``` -2. Edit `./Dockerfile` by adding (replace `` with the domain name - or IP address of the remote host which should provide CodeGate): +2. Edit `./Dockerfile` to add the `VITE_BASE_API_URL` environment variable + _before_ the web dashboard build step: - ```Dockerfile - ENV VITE_BASE_API_URL=http://:8989 - ``` - - before the CodeGate web dashboard is built: + ```dockerfile {1-3} title="./Dockerfile" + # Customize the API base URL + ENV VITE_BASE_API_URL=http://:8989 + # End customization - ```Dockerfile # Install the webapp dependencies and build it RUN npm install RUN npm run build ``` + Replace `` with the IP or DNS name of the remote host where + CodeGate will run. + 3. Build the customized Docker image on the remote host: ```shell make image-build ``` -4. Run the customized locally built Docker image: +4. Run the customized Docker image (built locally as `codegate:latest`): ```shell - docker run --name codegate -p 8989:8989 -p 9090:9090 codegate:latest + docker run --name codegate -d -p 8989:8989 -p 9090:9090 -p 8990:8990 --mount type=volume,src=codegate_volume,dst=/app/codegate_volume --restart unless-stopped codegate:latest ``` diff --git a/docs/how-to/install.md b/docs/how-to/install.md index 89f7be2..7f6c279 100644 --- a/docs/how-to/install.md +++ b/docs/how-to/install.md @@ -23,8 +23,8 @@ supposed to bind to _localhost_ (`127.0.0.1`) and remain inaccessible from remote hosts. If you are an advanced user who wants to run CodeGate on a remote host in a -secured/local network, consider the information given -[here](./configure.md#run-codegate-on-a-remote-host). +secured/local network, see +[Run CodeGate on a remote host](./configure.md#run-codegate-on-a-remote-host). ### Recommended settings From 7b1b282a29e133e614793797ede57b4c17372a4b Mon Sep 17 00:00:00 2001 From: Bernhard Froemel Date: Fri, 14 Feb 2025 19:28:09 +0100 Subject: [PATCH 4/4] added Dockerfile syntax highlighting per suggestion by Dan Barr --- docusaurus.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 8c1c847..dff66c5 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -182,7 +182,7 @@ const config: Config = { prism: { theme: prismThemes.github, darkTheme: prismThemes.dracula, - additionalLanguages: ['bash', 'json', 'powershell'], + additionalLanguages: ['bash', 'json', 'powershell', 'docker'], }, mermaid: { theme: { light: 'neutral', dark: 'dark' },