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

Create static/config.json from template file + ENV if not exist #511

Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ reflect the base URL of a Dependency-Track server.
![Deployment Options](https://raw.githubusercontent.com/DependencyTrack/frontend/master/docs/images/Frontend-Deployment.svg?sanitize=true)

The front-end is deployed to a general purpose web server (e.g. NGINX or Apache). To configure the front-end
for this scenario, simply change the value of API_BASE_URL in static/config.json.
for this scenario, simply copy `static/config.tmpl.json` to `static/config.json` and change the value of API_BASE_URL in `static/config.json`.

```json
{
Expand Down
18 changes: 9 additions & 9 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

set -e

# Check if config.json is mounted
if mount | grep '/static/config.json'; then
echo "config.json is mounted from host - ENV configuration will be ignored"
CONFIG_FILE="./static/config.json"
TEMPLATE_FILE="./static/config.tmpl.json"

# Check if config.json exists
if test -f $CONFIG_FILE; then
echo "config.json already exists - ENV variables will be ignored"
else
# Apply ENV vars to temporary config.json
echo "Creating config.json using ENV variables"
jq '.API_BASE_URL = env.API_BASE_URL
| .API_WITH_CREDENTIALS = env.API_WITH_CREDENTIALS
| .API_WITH_CREDENTIALS = env.API_WITH_CREDENTIALS
| .OIDC_ISSUER = env.OIDC_ISSUER
| .OIDC_CLIENT_ID = env.OIDC_CLIENT_ID
| .OIDC_SCOPE = env.OIDC_SCOPE
| .OIDC_FLOW = env.OIDC_FLOW
| .OIDC_LOGIN_BUTTON_TEXT = env.OIDC_LOGIN_BUTTON_TEXT' \
./static/config.json > /tmp/config.json

# Override default config file
mv -f /tmp/config.json ./static/config.json
$TEMPLATE_FILE > $CONFIG_FILE
fi

exec "$@"
muellerst-hg marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.