Skip to content
Merged
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: 9 additions & 2 deletions Dockerfiles/frontend_build.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
VITE_OBP_API_HOST=VITE_OBP_API_HOST
VITE_OBP_API_PORTAL_HOST=VITE_OBP_API_PORTAL_HOST
VITE_OBP_API_MANAGER_HOST=VITE_OBP_API_MANAGER_HOST
VITE_OBP_API_VERSION=v5.1.0

VITE_OBP_LOGO_URL=VITE_OBP_LOGO_URL
VITE_OBP_API_VERSION=VITE_OBP_API_VERSION
VITE_OBP_LINKS_COLOR=VITE_OBP_LINKS_COLOR
VITE_OBP_HEADER_LINKS_COLOR=VITE_OBP_HEADER_LINKS_COLOR
VITE_OBP_HEADER_LINKS_HOVER_COLOR=VITE_OBP_HEADER_LINKS_HOVER_COLOR
VITE_OBP_HEADER_LINKS_BACKGROUND_COLOR=VITE_OBP_HEADER_LINKS_BACKGROUND_COLOR
VITE_OBP_API_DEFAULT_RESOURCE_DOC_VERSION=VITE_OBP_API_DEFAULT_RESOURCE_DOC_VERSION
VITE_CHATBOT_ENABLED=VITE_CHATBOT_ENABLED
VITE_CHATBOT_URL=VITE_CHATBOT_URL
23 changes: 21 additions & 2 deletions Dockerfiles/prestart.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,35 @@ import (
"path/filepath"
"regexp"
"strings"
"fmt"
)

// As the frontend environment is read at build time, we need to reprocess the values
// at container runtime.
// This app will search and replace the values set at build time from this build environment: Dockerfiles/frontend_build.env
// with values taken from the container environment.

func main() {
// Define the host env variables to be replaced at build time
config := []string{"VITE_OBP_API_HOST", "VITE_OBP_API_MANAGER_HOST", "VITE_OBP_API_PORTAL_HOST"}
// Define the build env variables to be replaced at container run time
// url config variables are expected to be a valid URL in the container environment
url_config := []string{"VITE_OBP_API_HOST", "VITE_OBP_API_MANAGER_HOST", "VITE_OBP_API_PORTAL_HOST", "VITE_OBP_LOGO_URL"}
// DANGERZONE: The following strings will be replaced by container environment variables without any checking of whatever!!!
config := []string{"VITE_OBP_API_VERSION", "VITE_OBP_LINKS_COLOR", "VITE_OBP_HEADER_LINKS_COLOR", "VITE_OBP_HEADER_LINKS_HOVER_COLOR", "VITE_OBP_HEADER_LINKS_BACKGROUND_COLOR", "VITE_OBP_API_DEFAULT_RESOURCE_DOC_VERSION", "VITE_CHATBOT_ENABLED", "VITE_CHATBOT_URL"}
configMap := make(map[string]string)

for _, key := range config {
value := os.Getenv(key)
if value == "" {
fmt.Printf("Skipping: Environment variable %s is not set\n", key)
continue
}
configMap[key] = value
}

for _, key := range url_config {
rawURL := os.Getenv(key)
if rawURL == "" {
fmt.Printf("Skipping: Environment variable %s is not set\n", key)
continue
}
cleanURL := checkURL(rawURL)
Expand Down