Browse Source

update start / build / deploiement configs

Olivier Massot 4 years ago
parent
commit
e3af5bcf9d
4 changed files with 93 additions and 15 deletions
  1. 4 4
      .gitlab-ci.yml
  2. 62 5
      README.md
  3. 13 0
      ecosystem.config.js
  4. 14 6
      package.json

+ 4 - 4
.gitlab-ci.yml

@@ -30,7 +30,7 @@ chrome:
   image: cypress/browsers:node14.17.0-chrome88-ff89
   stage: test
   script:
-    - yarn ci & npx wait-on http://localhost:3004
+    - yarn dev:ci & npx wait-on http://localhost:3004
     - yarn cypress:run --browser chrome
   artifacts:
     when: on_failure
@@ -43,7 +43,7 @@ chrome-mobile:
   image: cypress/browsers:node14.17.0-chrome88-ff89
   stage: test
   script:
-    - yarn ci & npx wait-on http://localhost:3004
+    - yarn dev:ci & npx wait-on http://localhost:3004
     - yarn cypress:run --browser chrome --config "viewportWidth=375,viewportHeight=667"
   artifacts:
     when: on_failure
@@ -56,7 +56,7 @@ firefox:
   image: cypress/browsers:node14.17.0-chrome88-ff89
   stage: test
   script:
-    - yarn ci & npx wait-on http://localhost:3004
+    - yarn dev:ci & npx wait-on http://localhost:3004
     - yarn cypress:run --browser firefox
   artifacts:
     when: on_failure
@@ -69,7 +69,7 @@ firefox-mobile:
   image: cypress/browsers:node14.17.0-chrome88-ff89
   stage: test
   script:
-    - yarn ci & npx wait-on http://localhost:3004
+    - yarn dev:ci & npx wait-on http://localhost:3004
     - yarn cypress:run --browser firefox --config "viewportWidth=375,viewportHeight=667"
   artifacts:
     when: on_failure

+ 62 - 5
README.md

@@ -8,18 +8,76 @@ Iframes implémentées:
 
 * [Recherche des structures des fédérations](https://ressources.opentalent.fr/display/SPEC/Les+societes+adherentes)
 
-## Run / build
+A voir:
 
-To start the development server:
+* [vuejs.org](https://vuejs.org/v2/guide/)
+* [nuxtjs.org](https://fr.nuxtjs.org/docs/2.x/get-started/installation)
+* [vuetifyjs.com](https://vuetifyjs.com/en/)
+* [typescriptlang.org](https://www.typescriptlang.org/)
+* [jestjs.io](https://jestjs.io/docs/getting-started)
+* [cypress.io](https://docs.cypress.io/guides/getting-started/installing-cypress)
+* [pm2.keymetrics.io](https://pm2.keymetrics.io/docs/usage/quick-start//)
 
-    yarn dev
 
-To build:
+## Opérations courantes
 
+## Déploiement
+
+### Premier déploiement en tant que service
+
+> Prérequis 1 : PM2 doit être installé de manière globale sur la machine hôte (https://nuxtjs.org/deployments/pm2/)
+
+On commence par cloner le projet app, puis par se placer dans le répertoire ainsi créé.
+On créé un symlink vers le fichier .env.xxx voulu sous le nom de .env (selon l'environnement)
+
+    ln -s .env.xxx .env
+
+Pour déployer le projet en mode SSR, on commence par mettre à jour et compiler :
+
+    yarn install
     yarn build
 
+On lance ensuite le service avec :
+
+    pm2 start
+
+Vérifier le statut avec :
+
+    pm2 show frames
+
+On pourra ensuite interagir avec le service ainsi :
+
+    pm2 restart frames
+    pm2 stop frames
+    pm2 logs frames
+
+On enregistre le service pour qu'il soit relancé lors du boot de la machine:
+https://pm2.keymetrics.io/docs/usage/startup/
 
+En tant que non-root:
 
+    pm2 startup
+
+Puis, comme la commande précédente le suggère, on lance **en tant que root**:
+
+    
+
+On sauvegarde la nouvelle configuration avec:
+
+    pm2 save
+
+### Mettre à jour
+
+Se placer dans le répertoire de l'application, puis lancer:
+
+    yarn deploy
+
+Cette commande est un alias qui équivaut à lancer:
+
+    git pull
+    yarn install
+    yarn build
+    pm2 restart
 
 ## Run tests
 
@@ -27,7 +85,6 @@ To run unit tests:
 
     yarn test
 
-
 To run end-to-end tests with [Cypress](https://docs.cypress.io/guides/):
 
     yarn cypress

+ 13 - 0
ecosystem.config.js

@@ -0,0 +1,13 @@
+// PM2 configuration: https://nuxtjs.org/deployments/pm2/
+
+module.exports = {
+  apps: [
+    {
+      name: 'frames',
+      exec_mode: 'cluster',
+      instances: '1',
+      script: 'yarn',
+      args: 'start'
+    }
+  ]
+}

+ 14 - 6
package.json

@@ -3,12 +3,20 @@
   "version": "0.2.0",
   "private": true,
   "scripts": {
-    "dev": "nuxt --hostname '0.0.0.0' --port 3004 --dotenv .env.local",
-    "ci": "nuxt --hostname '0.0.0.0' --port 3004 --dotenv .env.ci",
+    "dev": "nuxt --hostname '0.0.0.0' --port 3004",
+    "dev:local": "yarn dev --dotenv .env.local",
+    "dev:preprod": "yarn dev --dotenv .env.preprod",
+    "dev:prod": "yarn dev --dotenv .env.prod",
+    "dev:ci": "yarn dev --dotenv .env.ci",
     "build": "nuxt build",
-    "build:preprod": "nuxt build --dotenv .env.preprod",
-    "start": "nuxt start",
-    "generate": "nuxt generate",
+    "build:local": "yarn build --dotenv .env.local",
+    "build:preprod": "yarn build --dotenv .env.preprod",
+    "build:prod": "yarn build --dotenv .env.prod",
+    "start": "nuxt start --hostname '127.0.0.1' --port 3004",
+    "start:local": "yarn start --dotenv .env.local",
+    "start:preprod": "yarn start --dotenv .env.preprod",
+    "start:prod": "yarn start --dotenv .env.prod",
+    "deploy": "git pull && yarn install && yarn build && pm2 start frames",
     "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
     "lint": "yarn lint:js",
     "test": "jest",
@@ -43,7 +51,7 @@
     "@vue/test-utils": "^1.2.1",
     "babel-core": "7.0.0-bridge.0",
     "babel-jest": "^27.0.5",
-    "cypress": "^8.5.0",
+    "cypress": "8.7.0",
     "eslint": "^7.29.0",
     "eslint-plugin-cypress": "^2.12.1",
     "eslint-plugin-nuxt": "^2.0.0",