-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix - upgrade package, add env-config file * fix - add scripts, entrypoint, env conf * fix - adapt components to env imports, remove config from appcontext * fix - finalize PR, remove useless files and config * fix - adapt dockerfile * fix - adapt dockerfile * fix - finalize PR, remove useless files and config * fix - remove useless oidctrusteddomains conf
- Loading branch information
1 parent
058de12
commit 01d16a6
Showing
22 changed files
with
87 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# REACT_APP_AUTH_TYPE: oidc / none, default: none | ||
REACT_APP_AUTH_TYPE=NONE | ||
REACT_APP_CLIENT_ID=myClient | ||
REACT_APP_AUTHORITY=https://auth.server | ||
REACT_APP_PORTAIL_URL=https://localhost:3000 | ||
REACT_APP_MANAGEMENT_API_BASE_URL=https://localhost:3001 | ||
REACT_APP_REALM=myRealm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,5 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
/public/OidcTrustedDomains.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
FROM nginx | ||
RUN rm -rf /usr/share/nginx/html/* | ||
|
||
ADD build /usr/share/nginx/html | ||
RUN rm etc/nginx/conf.d/default.conf | ||
COPY nginx.conf etc/nginx/conf.d/ | ||
|
||
# Copy .env file and shell script to container | ||
WORKDIR /usr/share/nginx/html | ||
COPY ./scripts/env.sh . | ||
COPY ./scripts/.env . | ||
|
||
# Make shell script executable and prevent windows encoding | ||
RUN sed -i -e 's/\r$//' env.sh && sed -i -e 's/\r$//' .env && chmod +x env.sh | ||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod 755 /entrypoint.sh | ||
ENTRYPOINT [ "/entrypoint.sh" ] | ||
|
||
# Start Nginx server | ||
CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""] | ||
CMD ["nginx", "-g", "daemon off;"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
echo "self._env_['REACT_APP_AUTH_TYPE'] = '$REACT_APP_AUTH_TYPE';" >> /usr/share/nginx/html/env-config.js | ||
echo "self._env_['REACT_APP_CLIENT_ID'] = '$REACT_APP_CLIENT_ID';" >> /usr/share/nginx/html/env-config.js | ||
echo "self._env_['REACT_APP_AUTHORITY'] = '$REACT_APP_AUTHORITY';" >> /usr/share/nginx/html/env-config.js | ||
echo "self._env_['REACT_APP_PORTAIL_URL'] = '$REACT_APP_PORTAIL_URL';" >> /usr/share/nginx/html/env-config.js | ||
echo "self._env_['REACT_APP_MANAGEMENT_API_BASE_URL'] = '$REACT_APP_MANAGEMENT_API_BASE_URL';" >> /usr/share/nginx/html/env-config.js | ||
echo "self._env_['REACT_APP_REALM'] = '$REACT_APP_REALM';" >> /usr/share/nginx/html/env-config.js | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* eslint-disable no-restricted-globals */ | ||
if (!self._env_) self._env_ = {}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const fs = require("fs"); | ||
|
||
fs.readFile(".env", "utf8", function (_, contents) { | ||
const content = contents | ||
.split("\n") | ||
.filter(line => !line.startsWith("#")) | ||
.map(line => line.split("=")) | ||
.filter(data => data.length === 2) | ||
.map(([key]) => `echo "self._env_['${key}'] = '$${key}';" >> /usr/share/nginx/html/env-config.js`); | ||
|
||
const fullFile = ["#!/bin/sh", ...content, 'exec "$@"'].join("\n"); | ||
fs.writeFileSync("entrypoint.sh", fullFile, "utf8"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* This function reads environment variables in the order: (If a value is found, it stops.) | ||
* - variables defined inside object window._env_ (env variable injected by environnment, docker) | ||
* @param varName : the variable name | ||
* @returns the value of variable name | ||
*/ | ||
export const getEnvVar = varName => { | ||
// eslint-disable-next-line no-restricted-globals | ||
return self?._env_?.[varName] || process.env[varName] || ""; | ||
}; | ||
|
||
export const environment = { | ||
API_URL: getEnvVar("REACT_APP_MANAGEMENT_API_BASE_URL"), | ||
AUTH_TYPE: getEnvVar("REACT_APP_AUTH_TYPE") || "NONE", | ||
PORTAIL_URL: getEnvVar("REACT_APP_PORTAIL_URL") || `${window.location.origin}`, | ||
}; | ||
|
||
export const oidcConf = { | ||
client_id: getEnvVar("REACT_APP_CLIENT_ID"), | ||
authority: getEnvVar("REACT_APP_AUTHORITY"), | ||
realm: getEnvVar("REACT_APP_REALM"), | ||
scope: "openid profile email offline_access", | ||
}; |