Skip to content

Commit

Permalink
Auto-set the GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE env var in t…
Browse files Browse the repository at this point in the history
…he container image

Setting it to an empty value allows global-agent to rely on the rather
conventional HTTP(S)_PROXY and NO_PROXY env vars. [1]
Otherwise, users would need to configure both GLOBAL_AGENT_HTTP(S)_PROXY
and HTTP(S)_PROXY to make proxying work with both global-agent and other
libs.
Also, it might be a bit confusing for the user to have to set it explicitly
to an empty value.
We can set it the other way around, but users can still override it if
needed.

[1] https://github.com/gajus/global-agent#what-is-the-reason-global-agentbootstrap-does-not-use-http_proxy
  • Loading branch information
rm3l committed May 6, 2024
1 parent 5a38d1c commit 3d6bec8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .rhdh/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ ENV CHOKIDAR_USEPOLLING='1' CHOKIDAR_INTERVAL='10000'
# To avoid running scripts when using `npm pack` to install dynamic plugins
ENV NPM_CONFIG_ignore-scripts='true'

# RHIDP-2217: corporate proxy support (configured using 'global-agent')
# This is to avoid having to define several environment variables for the same purpose,
# i.e, GLOBAL_AGENT_HTTP(S)_PROXY (for 'global-agent') and the conventional HTTP(S)_PROXY (honored by other libraries like Axios).
# By setting GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE to an empty value,
# 'global-agent' will use the same HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables.
ENV GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE=''

ENTRYPOINT ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.example.yaml", "--config", "app-config.example.production.yaml"]

# append Brew metadata here
7 changes: 7 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ ENV CHOKIDAR_USEPOLLING='1' CHOKIDAR_INTERVAL='10000'
# To avoid running scripts when using `npm pack` to install dynamic plugins
ENV NPM_CONFIG_ignore-scripts='true'

# RHIDP-2217: corporate proxy support (configured using 'global-agent')
# This is to avoid having to define several environment variables for the same purpose,
# i.e, GLOBAL_AGENT_HTTP(S)_PROXY (for 'global-agent') and the conventional HTTP(S)_PROXY (honored by other libraries like Axios).
# By setting GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE to an empty value,
# 'global-agent' will use the same HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables.
ENV GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE=''

ENTRYPOINT ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.example.yaml", "--config", "app-config.example.production.yaml"]

# append Brew metadata here
27 changes: 16 additions & 11 deletions showcase-docs/corporate-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

Out of the box, the Showcase application can be run behind a corporate proxy, by setting any of the following environment variables prior to starting the application:

- `GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE` to an empty value
- `HTTP_PROXY`: HTTP proxy to use.
- `HTTPS_PROXY`: distinct proxy to use for HTTPS requests.

Expand All @@ -16,8 +15,6 @@ You can set the proxy information in your Helm `values` file, like so:
upstream:
backstage:
extraEnvVars:
- name: GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE
value: ''
- name: HTTP_PROXY
# HTTP proxy to use
value: '<my_http_proxy_url>'
Expand All @@ -38,14 +35,12 @@ upstream:
upstream:
backstage:
extraEnvVars:
- name: GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE
value: ''
- name: HTTP_PROXY
value: 'http://10.10.10.105:3128'
- name: HTTPS_PROXY
value: 'http://10.10.10.106:3128'
- name: NO_PROXY
value: 'localhost,internal.example.org'
value: 'localhost,example.org'
```

</details>
Expand All @@ -59,8 +54,6 @@ spec:
application:
extraEnvs:
envs:
- name: GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE
value: ''
- name: HTTP_PROXY
# HTTP proxy to use
value: '<my_http_proxy_url>'
Expand All @@ -82,14 +75,26 @@ spec:
application:
extraEnvs:
envs:
- name: GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE
value: ''
- name: HTTP_PROXY
value: 'http://10.10.10.105:3128'
- name: HTTPS_PROXY
value: 'http://10.10.10.105:3128'
- name: NO_PROXY
value: 'localhost,internal.example.org'
value: 'localhost,example.org'
```

</details>

## Local development

If you are behind a corporate proxy and are running the Showcase locally, as depicted in [Running locally with a basic configuration](./getting-started.md#running-locally-with-a-basic-configuration) or [Running locally with the Optional Plugins](./getting-started.md#running-locally-with-the-optional-plugins), you will need to additionally set the `GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE` to an empty value prior to running `yarn start`.

Example:

```shell
$ GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE='' \
HTTP_PROXY=http://10.10.10.105:3128 \
HTTPS_PROXY=http://10.10.10.106:3128 \
NO_PROXY='localhost,example.org' \
yarn start
```

0 comments on commit 3d6bec8

Please sign in to comment.