Browse Source

update build configuration

Olivier Massot 4 years ago
parent
commit
45df1136f2
6 changed files with 44 additions and 26 deletions
  1. 2 0
      .env.local
  2. 2 0
      .env.preprod
  3. 3 0
      .env.prod
  4. 23 15
      README.md
  5. 2 2
      ecosystem.config.js
  6. 12 9
      package.json

+ 2 - 0
.env.local

@@ -1,3 +1,5 @@
+## LOCAL ENVIRONMENT FILE
+
 ## API Base Url
 SSR_API_BASE_URL=http://nginx_new
 CLIENT_API_BASE_URL=https://local.new.api.opentalent.fr

+ 2 - 0
.env.preprod

@@ -1,3 +1,5 @@
+## PREPROD ENVIRONMENT FILE
+
 ## API Base Url
 SSR_API_BASE_URL = https://ap2i.preprod.opentalent.fr
 CLIENT_API_BASE_URL = https://ap2i.preprod.opentalent.fr

+ 3 - 0
.env.prod

@@ -1,3 +1,6 @@
+## PROD ENVIRONMENT FILE
+# /!\ -- USE ONLY IN PRODUCTION --
+
 ## API Base Url
 SSR_API_BASE_URL = https://ap2i.opentalent.fr
 CLIENT_API_BASE_URL = https://ap2i.opentalent.fr

+ 23 - 15
README.md

@@ -1,7 +1,7 @@
 # app
 
-[![pipeline status](http://gitlab.2iopenservice.com/vincent/admin/badges/master/pipeline.svg)](http://gitlab.2iopenservice.com/vincent/admin/-/commits/master)
-[![coverage report](http://gitlab.2iopenservice.com/vincent/admin/badges/master/coverage.svg)](http://gitlab.2iopenservice.com/vincent/admin/-/commits/master)
+[![pipeline status](http://gitlab.2iopenservice.com/vincent/admin/badges/master/pipeline.svg)](http://gitlab.2iopenservice.com/opentalent/admin/-/commits/master)
+[![coverage report](http://gitlab.2iopenservice.com/vincent/admin/badges/master/coverage.svg)](http://gitlab.2iopenservice.com/opentalent/admin/-/commits/master)
 
 Frontend développé avec Vue.js 2 + NuxtJs 2
 
@@ -19,28 +19,26 @@ A voir:
 
 ## Opérations courantes
 
-### Déployer en tant que service
+## Déploiement
 
-> Prérequis : PM2 doit être installé de manière globale sur la machine hôte (https://nuxtjs.org/deployments/pm2/)
+### 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
 
-    // en prod
-    yarn build:prod
-    
-    // en preprod
-    yarn build:preprod
+On lance ensuite le service avec :
 
-On lance ensuite le service avec:
-
-    // si le service n'est pas encore démarré
     pm2 start
 
-    // si le service est démarré
-    pm2 restart app
-
 Vérifier le statut avec :
  
     pm2 show app
@@ -51,6 +49,16 @@ On pourra ensuite interagir avec le service ainsi :
     pm2 stop app
     pm2 logs app
 
+### Mettre à jour
+
+Se place dans le répertoire de l'application, puis lancer:
+
+    git pull
+    yarn install
+    pm2 restart
+
+## Autres
+
 ### Lancer les tests
 
 Pour lancer les tests unitaires:

+ 2 - 2
ecosystem.config.js

@@ -6,8 +6,8 @@ module.exports = {
       name: 'app',
       exec_mode: 'cluster',
       instances: '1',
-      script: './node_modules/nuxt/bin/nuxt.js',
-      args: 'start --hostname \'0.0.0.0\' --port 3002'
+      script: 'yarn',
+      args: 'start'
     }
   ]
 }

+ 12 - 9
package.json

@@ -3,15 +3,18 @@
   "version": "0.1.0",
   "private": true,
   "scripts": {
-    "dev": "yarn dev:local",
-    "dev:local": "nuxt --hostname '0.0.0.0' --port 3002 --dotenv .env.local",
-    "dev:preprod": "nuxt --hostname '0.0.0.0' --port 3002 --dotenv .env.preprod",
-    "dev:prod": "nuxt --hostname '0.0.0.0' --port 3002 --dotenv .env.prod",
-    "build": "yarn build:local",
-    "build:local": "nuxt build --dotenv .env.local",
-    "build:preprod": "nuxt build --dotenv .env.preprod",
-    "build:prod": "nuxt build --dotenv .env.prod",
-    "start": "nuxt start --hostname '0.0.0.0' --port 3002",
+    "dev": "nuxt --hostname '0.0.0.0' --port 3002",
+    "dev:local": "yarn dev --dotenv .env.local",
+    "dev:preprod": "yarn dev --dotenv .env.preprod",
+    "dev:prod": "yarn dev --dotenv .env.prod",
+    "build": "nuxt build",
+    "build:local": "yarn build --dotenv .env.local",
+    "build:preprod": "yarn build --dotenv .env.preprod",
+    "build:prod": "yarn build --dotenv .env.prod",
+    "start": "yarn start --hostname '127.0.0.1' --port 3002",
+    "start:local": "yarn start --dotenv .env.local",
+    "start:preprod": "yarn start --dotenv .env.preprod",
+    "start:prod": "yarn start --dotenv .env.prod",
     "lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .",
     "lint": "yarn lint:js",
     "test": "jest",