From 4387a868bc81f9929a8b2f28a2c978249f905d5b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Jul 2024 09:36:25 +0200 Subject: [PATCH] perf: update --- Jenkinsfile | 100 +++++++++++++++++++++++++++-------------------- package.json | 3 +- src/boot/i18n.js | 33 +++++++++------- 3 files changed, 78 insertions(+), 58 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 11b267b2..ef4c3583 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,34 +1,25 @@ #!/usr/bin/env groovy +def BRANCH_ENV = [ + test: 'test', + master: 'production' +] +def remote = [:] + +node { + stage('Setup') { + env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev' + + echo "NODE_NAME: ${env.NODE_NAME}" + echo "WORKSPACE: ${env.WORKSPACE}" + } +} pipeline { agent any environment { PROJECT_NAME = 'hedera-web' - STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" } stages { - stage('Checkout') { - steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = packageJson.version - - switch (env.BRANCH_NAME) { - case 'master': - env.NODE_ENV = 'production' - env.MAIN_REPLICAS = 3 - env.CRON_REPLICAS = 1 - break - case 'test': - env.NODE_ENV = 'test' - env.MAIN_REPLICAS = 1 - env.CRON_REPLICAS = 0 - break - } - } - setEnv() - } - } stage('Debuild') { when { anyOf { @@ -38,31 +29,28 @@ pipeline { } agent { docker { - image 'registry.verdnatura.es/debuild:2.21.3-vn2' + image 'registry.verdnatura.es/verdnatura/debuild:2.23.4-vn7' registryUrl 'https://registry.verdnatura.es/' registryCredentialsId 'docker-registry' - args '-v /mnt/appdata/reprepro:/reprepro' } } steps { sh 'debuild -us -uc -b' - sh 'vn-includedeb stretch' - } - } - stage('Container') { - when { - anyOf { - branch 'master' - branch 'test' + sh 'mkdir -p debuild' + sh 'mv ../hedera-web_* debuild' + + script { + def files = findFiles(glob: 'debuild/*.changes') + files.each { file -> env.CHANGES_FILE = file.name } + } + + configFileProvider([ + configFile(fileId: "dput.cf", variable: 'DPUT_CONFIG') + ]) { + sshagent(credentials: ['jenkins-agent']) { + sh 'dput --config "$DPUT_CONFIG" verdnatura "debuild/$CHANGES_FILE"' + } } - } - environment { - CREDS = credentials('docker-registry') - } - steps { - sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY' - sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel' - sh 'docker-compose push' } } stage('Deploy') { @@ -73,15 +61,41 @@ pipeline { } } environment { - DOCKER_HOST = "${env.SWARM_HOST}" + CREDS = credentials('docker-registry') + IMAGE = "$REGISTRY/verdnatura/hedera-web" } steps { - sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" + script { + def packageJson = readJSON file: 'package.json' + env.VERSION = "${packageJson.version}" + env.TAG = "${packageJson.version}-build${env.BUILD_ID}" + } + + sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel' + sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY' + sh 'docker push $IMAGE:$TAG' + + script { + if (env.BRANCH_NAME == 'master') { + sh 'docker tag $IMAGE:$TAG $IMAGE:latest' + sh 'docker push $IMAGE:latest' + } + } + + withKubeConfig([ + serverUrl: "$KUBERNETES_API", + credentialsId: 'kubernetes', + namespace: 'salix' + ]) { + sh 'kubectl set image deployment/hedera-web-$BRANCH_NAME hedera-web-$BRANCH_NAME=$IMAGE:$TAG' + sh 'kubectl set image deployment/hedera-web-cron-$BRANCH_NAME hedera-web-cron-$BRANCH_NAME=$IMAGE:$TAG' + } } } } post { unsuccessful { + setEnv() sendEmail() } } diff --git a/package.json b/package.json index 66d12b44..038fc74c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "22.48.2", "description": "Verdnatura web page", "license": "GPL-3.0", - "author": "Juan Ferrer Toribio ", + "productName": "Salix", + "author": "Verdnatura", "repository": { "type": "git", "url": "https://git.verdnatura.es/hedera-web" diff --git a/src/boot/i18n.js b/src/boot/i18n.js index 85d0f9df..8b7e956d 100644 --- a/src/boot/i18n.js +++ b/src/boot/i18n.js @@ -1,18 +1,23 @@ -import { boot } from 'quasar/wrappers' -import { createI18n } from 'vue-i18n' -import messages from 'src/i18n' +import { boot } from 'quasar/wrappers'; +import { createI18n } from 'vue-i18n'; +import messages from 'src/i18n'; +const i18n = createI18n({ + locale: navigator.language || navigator.userLanguage, + fallbackLocale: 'en', + globalInjection: true, + missingWarn: false, + fallbackWarn: false, + legacy: false, + silentTranslationWarn: true, + silentFallbackWarn: true, + messages +}); export default boot(({ app }) => { - const i18n = createI18n({ - locale: 'es-ES', - globalInjection: true, - silentTranslationWarn: true, - silentFallbackWarn: true, - messages - }) - // Set i18n instance on app - app.use(i18n) + app.use(i18n); - window.i18n = i18n.global -}) + window.i18n = i18n.global; +}); + +export { i18n };