[WIFI-7463] Chg: modify Docker runtime files to support new version

Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
This commit is contained in:
Dmitry Dunaev
2022-03-29 15:15:39 +03:00
parent 9554b96f6f
commit 16d95ba6bb
5 changed files with 34 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
FROM node:14-alpine3.14 AS build
FROM node:16-alpine3.15 AS build
COPY package.json package-lock.json /
COPY . .
RUN npm install

View File

@@ -1,6 +1,32 @@
#!/bin/ash
# Check if variables are set
export DEFAULT_UCENTRALSEC_URL="${DEFAULT_UCENTRALSEC_URL:-https://localhost:16001}"
export ALLOW_UCENTRALSEC_CHANGE="${ALLOW_UCENTRALSEC_CHANGE:-false}"
echo '{"DEFAULT_UCENTRALSEC_URL": "'$DEFAULT_UCENTRALSEC_URL'","ALLOW_UCENTRALSEC_CHANGE": '$ALLOW_UCENTRALSEC_CHANGE'}' > /usr/share/nginx/html/config.json
ENV_CONFIG_PATH=/usr/share/nginx/html/env-config.js
# Recreate config file
rm -rf $ENV_CONFIG_PATH
touch $ENV_CONFIG_PATH
# Add assignment
echo "window._env_ = {" >> $ENV_CONFIG_PATH
# Read each line in .env file
# Each line represents key=value pairs
env | grep REACT_ | while read -r line || [[ -n "$line" ]];
do
echo $line
# Split env variables by character `=`
if printf '%s\n' "$line" | grep -q -e '='; then
varname=$(printf '%s\n' "$line" | sed -e 's/=.*//')
varvalue=$(printf '%s\n' "$line" | sed -e 's/^[^=]*=//')
fi
# Read value of current variable if exists as Environment variable
value=$(printf '%s\n' "${!varname}")
# Otherwise use value from .env file
[[ -z $value ]] && value=${varvalue}
# Append configuration property to JS file
echo " $varname: \"$value\"," >> $ENV_CONFIG_PATH
done
echo "}" >> $ENV_CONFIG_PATH

View File

@@ -75,5 +75,4 @@ podAnnotations: {}
# Application
public_env_variables:
DEFAULT_UCENTRALSEC_URL: https://ucentral.dpaas.arilia.com:16001
ALLOW_UCENTRALSEC_CHANGE: false
REACT_APP_UCENTRALSEC_URL: https://ucentral.dpaas.arilia.com:16001

View File

@@ -5,6 +5,7 @@
<link rel="icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<script src="/env-config.js"></script>
<title>Provisioning</title>
</head>
<body>

View File

@@ -1,7 +1,7 @@
import * as axios from 'axios';
import { AUTH_EXPIRED_TOKEN_CODE, AUTH_INVALID_TOKEN_CODE } from 'constants/apiErrors';
export const secUrl = `${process.env.REACT_APP_UCENTRALSEC_URL}/api/v1`;
export const secUrl = `${window._env_.REACT_APP_UCENTRALSEC_URL || process.env.REACT_APP_UCENTRALSEC_URL}/api/v1`;
const sec = axios.create({ baseURL: secUrl });
sec.defaults.timeout = 60000;