diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed5ed7f9b442910eefc3d0629c66ea7a5d1e3d02..f69b2de6432b628a39076d16a2df277a83ab9508 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,6 @@ stages: - sonar-analysis - build - - deploy variables: SONAR_URL: https://sonarqube.forge.grandlyon.com @@ -9,7 +8,7 @@ variables: sonarqube: stage: sonar-analysis only: - - development + - master before_script: - export PATH=$PATH:/usr/local/bin/sonar-scanner-3.2.0.1227-linux/bin/ - export NODE_PATH=$NODE_PATH:`npm root -g` @@ -31,12 +30,14 @@ build_development: only: - development script: - - export TAG=dev - - export APP_PORT=8090 + - export TAG=$CI_COMMIT_SHORT_SHA + - echo ${TAG} + - export ADMIN_GUI_BIND_PORT=8090 - export CONFIG_FILE_PATH=./config/config.json - docker-compose build --build-arg conf=prod admin-gui - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker-compose push + - "curl -X POST -F token=$CI_JOB_TOKEN -F ref=master -F variables[TAG]=${TAG} https://forge.grandlyon.com/api/v4/projects/320/trigger/pipeline" build_release: stage: build @@ -46,40 +47,9 @@ build_release: - tags script: - export TAG=$(echo $CI_COMMIT_TAG | sed 's/v//g') - - export APP_PORT=8090 + - echo ${TAG} + - export ADMIN_GUI_BIND_PORT=8090 - export CONFIG_FILE_PATH=./config/config.json - docker-compose build --build-arg conf=prod admin-gui - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker-compose push - -deploy_development: - stage: deploy - only: - - development - script: - - export TAG=dev - - export APP_PORT=8090 - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker-compose pull - - export CONFIG_FILE_PATH=./config/config-dev.json - - docker-compose --project-name admin-gui-${TAG} up -d --force-recreate - environment: - name: development - -deploy_staging: - stage: deploy - only: - - development - when: manual - script: - - export TAG=staging - - export APP_PORT=8190 - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - TAG=dev docker-compose pull - - export REGISTRY_PATH=web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/custom-apps/admin-gui - - docker tag $CI_REGISTRY/$REGISTRY_PATH:dev $CI_REGISTRY/$REGISTRY_PATH:${TAG} - - docker push $CI_REGISTRY/$REGISTRY_PATH:${TAG} - - export CONFIG_FILE_PATH=./config/config-rec.json - - docker-compose --project-name admin-gui-${TAG} up -d --force-recreate - environment: - name: staging diff --git a/README.md b/README.md index 4380d9cb0e3d8376ae065be8ea769cab89d5dd9a..192c1efd31a82995127e9d3864cbc2ba0c043c7c 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,71 @@ -# AdminGui +# Admin GUI -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.8. +## Installation and usage -## Development server +The interface has been developed with the Angular framework, so you need to have Node.js installed on your machine in order to run the web application. +Once you have Node.js installed you need to install the Angular CLI. Open a command line and run: -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. +```bash +npm install -g @angular/cli +``` -## Code scaffolding +### Configuration -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. +Open the /src/assets/config/config.json file and update the configuration in order to match yours. -## Build +### Run the web application -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. +Using the Angular CLI: -## Running unit tests +```bash +ng serve +``` -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). +Using the npm script (which use the Angular CLI): -## Running end-to-end tests +```bash +npm run start +``` -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). +### Build the application -## Further help +We defined in the package.json two scripts that can build the application. One that generates an optimized build and the other an unoptimized build. The optimized build takes longer than the normal one. +Those two scripts contain an option --max_old_space_size=\<nb of max RAM octets the node process can take\>. Make sure the number does not exceed your RAM capacity (you can simply remove the option, it will use the default value: 512mb on 32-bit systems and 1gb on 64-bit systems). By incrising the node process memory limit we decrease the build time. -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). +For development environment (not optimized) + +```bash +npm run build:dev +``` + +For production environment (optimized) + +```bash +npm run build:prod +``` + +### Build and deploy with Docker + +The related files are: + +* docker-compose.yml which indicates what Dockerfile should be used, what image is going to be build, volumes, exposed port... +* Dockerfile which describe the steps to build the docker image. + +Some environment variables need to be set before building or running the image. Use the appropriate command to set those variables: SET on Windows, export on Linux. + +```bash +export TAG=<version> +export ADMIN_GUI_BIND_PORT=<port the application should be running on> +``` + +Then to build the image run: + +```bash +docker-compose build --build-arg conf=prod admin-gui #you can change prod to dev if you don't want an optimized build +``` + +Once the image is built on your machine, run the following command to start a container: + +```bash +docker-compose --project-name admin-gui up +``` diff --git a/config/config-dev.json b/config/config-dev.json deleted file mode 100644 index 877d18c7a3333aceb727d12447932f97a1ae5bc1..0000000000000000000000000000000000000000 --- a/config/config-dev.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "organizations": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/organizations/organizations/" - }, - "resources": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/resources/" - }, - "mediaLibrary": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/media-library/" - }, - "authentication": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/authentication/" - }, - "middlewareLegacyAuth": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/middleware-legacy/" - }, - "changelog": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/changelog/" - }, - "credits": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/credits/credits/" - }, - "restHeartAggregations": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/indexer-logs/indexerdb/" - }, - "reuses": { - "url": "https://data-reloaded-dev.alpha.grandlyon.com/api/reuses/" - } -} diff --git a/config/config-rec.json b/config/config-rec.json deleted file mode 100644 index f4157616e3d763c8b38bfd2cd2e2a59b28b7f041..0000000000000000000000000000000000000000 --- a/config/config-rec.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "organizations": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/organizations/organizations/" - }, - "resources": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/resources/" - }, - "mediaLibrary": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/media-library/" - }, - "authentication": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/authentication/" - }, - "middlewareLegacyAuth": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/middleware-legacy/" - }, - "changelog": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/changelog/" - }, - "credits": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/credits/credits/" - }, - "reuses": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/reuses/" - }, - "restHeartAggregations": { - "url": "https://data-reloaded-rec.alpha.grandlyon.com/api/indexer-logs/indexerdb/" - } -} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ed0e9f5c8f31eb81211c21aca829cca912095dc4..f153378c85834796666b41e9b39a88b028593ef1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,8 @@ services: build: . image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/custom-apps/admin-gui:${TAG} volumes: - - ${PWD}/nginx.conf.template:/etc/nginx/sites-enabled/default:ro - - ${CONFIG_FILE_PATH}:/usr/share/nginx/html/admin/assets/config/config.json:ro + - ./nginx.conf.template:/etc/nginx/sites-enabled/default:ro ports: - - ${APP_PORT}:8080 + - ${ADMIN_GUI_BIND_PORT}:8080 restart: unless-stopped