Commit 0a562b87 authored by Axel Bocciarelli's avatar Axel Bocciarelli
Browse files

Merge branch 'env' into 'master'

Move ICAT+ server URL to environment variable

See merge request !431
parents 5d032476 4e7fbc35
Pipeline #32443 passed with stages
in 7 minutes and 27 seconds
#####
# REACT-APP CONFIGURATION
####
EXTEND_ESLINT=true
#####
# PORTAL CONFIGURATION
# For test and production overrides, see `.env.test` and `.env.production`.
# To override one of these variables in development, create a file called `.env.local`.
#####
# ICAT+ SERVER URL
REACT_APP_ICATPLUS_URL=http://localhost:8000
# ICAT+ SERVER URL
REACT_APP_ICATPLUS_URL=https://icatplus.esrf.fr
# ICAT+ SERVER URL
REACT_APP_ICATPLUS_URL=https://icatplus.test
*~
# These configurations files are ignored and managed locally. These scripts will be copied from example when running the npm script configure that is called from npm run-script build
src/config/icat/icatPlus.js
src/config/icat/icat.js
# See https://help.github.com/ignore-files/ for more about ignoring files.
# personal folders. Not for production
/forDevOnly
/doc
# dependencies
/node_modules
# testing
/coverage
# production
/build
# Configurations files
/src/config/icat/icat.js
# misc
.DS_Store
# Local environment files
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Dependencies
/node_modules/
# eclipse
.settings
# Build outputs, reports and cache folders
/coverage/
/build/
/lib-cov/
/.nyc_output/
/.npm/
/.eslintcache/
# Logs
logs
*.log
# Miscellaneous
*~
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
# Personal folders
/forDevOnly/
/doc/
......@@ -27,24 +27,23 @@ Currently, datahub depends on:
## Installation procedure
1. Download the source code from [gitlab](https://gitlab.esrf.fr/icat/E-DataPortal) repository
2. Install dependencies
1. Clone or download the project from [GitLab](https://gitlab.esrf.fr/icat/E-DataPortal)
2. Install the dependencies
```bash
npm install
```
3. Configure datahub app. See this [section](#configuration).
```bash
npm install
```
4. Run the app
3. [Configure the app](#configuration)
4. Start the app
```bash
npm start
```
```bash
npm start
```
# Configuration
Datahub configuration is spread among different files located in the folder **src/config**. These files are:
Datahub configuration is spread among different files located in <kbd>src/config</kbd>. These files are:
- [icat.js](#icatjs) : configure access to the metadata catalogue.
- [icatPlus.js](#icatplusjs) : configure access to the ICAT+ server
......@@ -52,13 +51,14 @@ Datahub configuration is spread among different files located in the folder **sr
- [gui.config.js](#guiconfigjs) : configuration file for the logbook (to be moved to config.js)
- [config.js](#configjs) : UI general configuration of the GUI
Example files for [icat.js](src/config/icat/icat.example.js) and [icatPlus.js](src/config/icat/icatPlus.example.js) are provided and needs to be copied in configuration file:
Some of the configuration options in these files are stored in [environment variables](#environment-variables).
Example file for [icat.js](src/config/icat/icat.example.js) is provided and needs to be copied in configuration file:
You can copy them manually:
You can copy it manually:
```bash
cp src/config/icat/icat.example.js src/config/icat/icat.js
cp src/config/icat/icatPlus.example.js src/config/icat/icatPlus.js
```
or run:
......@@ -67,6 +67,17 @@ or run:
npm run-script configure
```
## Environment variables
Create React App loads environment variables from [environment files](https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used) (<kbd>.env</kbd>, <kbd>.env.test</kbd>, etc.) according to the Node environment (`NODE_ENV`).
File <kbd>.env</kbd> is loaded in every environment with the lowest priority and is therefore used to declare default values and development fallbacks.
The following portal configuration variable is currently declared in <kbd>.env</kbd>:
- `REACT_APP_ICATPLUS_URL` - the URL of the ICAT+ server (used in <kbd>src/config/icatPlus.js</kbd>)
In development, you can override this variable by creating a file called `.env.local`. This file is ignored from version control.
## icat.js
Edit the file **icat.js** with your favorite text editor and set the configuration to access the metadata catalogue following the indications below.
......@@ -123,26 +134,6 @@ export default ICAT;
<!--END configurationICAT -->
## icatPlus.js
Edit the file **icatPlus.js** with your favorite text editor and set the configuration to access the ICAT+ application following the indications below.
<!--START configurationICATPlus -->
```js
/**
* icatPlus.example.js configuration file
*/
var ICATPLUS = {
/** URL of ICAT+ server */
server: 'https://icatplus.esrf.fr',
};
export default ICATPLUS;
```
<!--END configurationICATPlus -->
## techniques.js
The file [techniques.js](src/config/techniques/techniques.js) complements short named techniques as stored in ICAT metadata catalogue. It maps a short name to a description and display settings.
......
......@@ -9,14 +9,12 @@
},
"scripts": {
"build": "npm run configure && react-scripts build",
"configure": "echo 'Copying config/icat/icatPlus.example.js and config/icat/icat.example.js' && cp src/config/icat/icatPlus.example.js src/config/icat/icatPlus.js && cp src/config/icat/icat.example.js src/config/icat/icat.js",
"configure": "echo 'Copying config/icat/icat.example.js' && cp src/config/icat/icat.example.js src/config/icat/icat.js",
"start": "react-scripts start",
"test": "react-scripts test --env=jsdom-fourteen",
"doc": "npm run Readme:ConfigDoc:ICAT && npm run Readme:ConfigDoc:ICAT:ReplaceCodeSection && npm run Readme:ConfigDoc:ICATPlus && npm run Readme:ConfigDoc:ICATPlus:ReplaceCodeSection && npm run Readme:ConfigDoc:Config && npm run Readme:ConfigDoc:Config:ReplaceCodeSection",
"Readme:ConfigDoc:ICAT": "node ./node_modules/jscat/bin/jscat src/config/icat/icat.example.js | node ./node_modules/injectmd/bin/cli.js -t configurationICAT -i Readme.md",
"Readme:ConfigDoc:ICAT:ReplaceCodeSection": "./node_modules/replace/bin/replace.js '<!--START configurationICAT -->' '<!--START configurationICAT -->\n```js' Readme.md && ./node_modules/replace/bin/replace.js '<!--END configurationICAT -->' '```\n<!--END configurationICAT -->' Readme.md",
"Readme:ConfigDoc:ICATPlus": "node ./node_modules/jscat/bin/jscat src/config/icat/icatPlus.example.js | node ./node_modules/injectmd/bin/cli.js -t configurationICATPlus -i Readme.md",
"Readme:ConfigDoc:ICATPlus:ReplaceCodeSection": "./node_modules/replace/bin/replace.js '<!--START configurationICATPlus -->' '<!--START configurationICATPlus -->\n```js' Readme.md && ./node_modules/replace/bin/replace.js '<!--END configurationICATPlus -->' '```\n<!--END configurationICATPlus -->' Readme.md",
"Readme:ConfigDoc:Config": "node ./node_modules/jscat/bin/jscat src/config/ui/config.js | node ./node_modules/injectmd/bin/cli.js -t config -i Readme.md",
"Readme:ConfigDoc:Config:ReplaceCodeSection": "./node_modules/replace/bin/replace.js '<!--START config -->' '<!--START config -->\n```js' Readme.md && ./node_modules/replace/bin/replace.js '<!--END config -->' '```\n<!--END config -->' Readme.md",
"complexity-report": "./node_modules/.bin/es6-plato -r -d ./public/report src",
......
/**
* icatPlus.example.js configuration file
*/
const ICATPLUS = {
/** URL of ICAT+ server */
server: 'https://icatplus.esrf.fr',
};
export default ICATPLUS;
const ICAT_PLUS = {
/** URL of ICAT+ server */
server: process.env.REACT_APP_ICATPLUS_URL,
};
export default ICAT_PLUS;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment