From f6c933dd5f4ce06cc7d4a9316abebcca13784df2 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Tue, 10 Jul 2018 10:47:46 -0700 Subject: [PATCH 1/3] Remove plumber so that gulp script dies when failure occurs --- gulpfile.babel.js | 15 ++++++--------- package.json | 1 - 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 9a6c6f15b04..fbd48081648 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -16,18 +16,16 @@ import watch from 'gulp-watch'; const $ = gulpLoadPlugins(); const browserSync = require('browser-sync').create(); const isProduction = process.env.NODE_ENV === 'production'; -const onError = (err) => { - console.log(err); -} -console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&') -console.log(process.env) -console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&') -process.on('SIGINT', () => { - console.log('Caught SIGINT, exiting'); +process.on('SIGINT', (err) => { + console.log('Caught SIGINT, exiting', '\r\n', err); process.exit(0); }); +process.on('uncaughtException', (err) => { + console.log('Uncaught Exception, exiting', '\r\n', err); + process.exit(1); +}); // -- gulp.task('dev', ['build-dev'], () => { gulp.start('init-watch'); @@ -103,7 +101,6 @@ gulp.task('sass', () => { return gulp.src([ 'src/sass/**/*.scss' ]) - .pipe($.plumber({ errorHandler: onError })) .pipe($.sassLint()) .pipe($.sassLint.format()) .pipe($.sass({ precision: 5, importer: tildeImporter })) diff --git a/package.json b/package.json index e914938dc52..6ef83f75291 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "gulp-imagemin": "^4.1.0", "gulp-load-plugins": "^1.5.0", "gulp-newer": "^1.3.0", - "gulp-plumber": "^1.1.0", "gulp-sass": "^3.1.0", "gulp-sass-lint": "^1.3.2", "gulp-size": "^3.0.0", From 94882d90475b8be5a64c34918f2b0e036852a005 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Tue, 10 Jul 2018 11:59:23 -0700 Subject: [PATCH 2/3] build updates --- .drone.yml | 24 +++--------------------- Dockerfile.prod | 1 + Dockerfile.staging | 1 + gulpfile.babel.js | 30 ++++++++++++++++++++++++++++-- scripts/build-algolia.js | 12 ++---------- 5 files changed, 35 insertions(+), 33 deletions(-) diff --git a/.drone.yml b/.drone.yml index e4dd2da5704..a719452dea7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,13 +18,7 @@ pipeline: repo: rancher/docs context: . tag: dev - secrets: [docker_username, docker_password, algolia_app_id, algolia_admin_key] - build_args: - - ALGOLIA_INDEX_NAME=dev_docs - - ALGOLIA_INDEX_FILE=public/algolia.json - build_args_from_env: - - ALGOLIA_APP_ID - - ALGOLIA_ADMIN_KEY + secrets: [docker_username, docker_password] when: branch: master event: push @@ -36,13 +30,7 @@ pipeline: repo: rancher/docs context: . tag: staging - secrets: [docker_username, docker_password, algolia_app_id, algolia_admin_key] - build_args: - - ALGOLIA_INDEX_NAME=dev_docs - - ALGOLIA_INDEX_FILE=public/algolia.json - build_args_from_env: - - ALGOLIA_APP_ID - - ALGOLIA_ADMIN_KEY + secrets: [docker_username, docker_password] when: branch: master event: push @@ -54,13 +42,7 @@ pipeline: repo: rancher/docs context: . tag: latest - secrets: [docker_username, docker_password, algolia_app_id, algolia_admin_key] - build_args: - - ALGOLIA_INDEX_NAME=prod_docs - - ALGOLIA_INDEX_FILE=public/algolia.json - build_args_from_env: - - ALGOLIA_APP_ID - - ALGOLIA_ADMIN_KEY + secrets: [docker_username, docker_password] when: branch: master event: push diff --git a/Dockerfile.prod b/Dockerfile.prod index 9869a6412e5..8be911c05fb 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -34,5 +34,6 @@ RUN gulp build RUN stat /run/public/index.html FROM nginx +VOLUME /usr/share/nginx/html/docs COPY --from=build /run/public /usr/share/nginx/html/docs/ COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/Dockerfile.staging b/Dockerfile.staging index d400d2f4be5..2cd841f0991 100644 --- a/Dockerfile.staging +++ b/Dockerfile.staging @@ -33,5 +33,6 @@ RUN gulp build-staging RUN stat /run/public/index.html FROM nginx +VOLUME /usr/share/nginx/html/docs COPY --from=build /run/public /usr/share/nginx/html/docs/ COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/gulpfile.babel.js b/gulpfile.babel.js index fbd48081648..01d6fd4044f 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -5,13 +5,15 @@ import gulp from 'gulp'; import del from 'del'; import runSequence from 'run-sequence'; import gulpLoadPlugins from 'gulp-load-plugins'; -import { spawn } from "child_process"; +import { spawn, exec } from "child_process"; import tildeImporter from 'node-sass-tilde-importer'; import browserify from 'browserify'; import source from 'vinyl-source-stream'; import buffer from 'vinyl-buffer'; import babelify from 'babelify'; import watch from 'gulp-watch'; +const atomicalgolia = require("atomic-algolia"); +const fs = require('fs'); const $ = gulpLoadPlugins(); const browserSync = require('browser-sync').create(); @@ -166,7 +168,6 @@ gulp.task('pub-delete', () => { return del(['public/**', '!public']); }); - gulp.task('build:search-index', (cb) => { const env = process.env; @@ -178,3 +179,28 @@ gulp.task('build:search-index', (cb) => { cb(); }); }); + + +gulp.task('publish:search-index', (cb) => { + const env = process.env; + + const opts = { + stdio: 'inherit', + env: env + }; + + return exec('giddyup leader check', opts).on('close', code => { + + if (code === 0) { + + const rawdata = fs.readFileSync('public/final.algolia.json'); + const merged = JSON.parse(rawdata); + atomicalgolia(process.env.ALGOLIA_INDEX_NAME, merged, (err, result) => { + console.log(result); + cb(err); + }); + + } + + }); +}); diff --git a/scripts/build-algolia.js b/scripts/build-algolia.js index 8432ac104fb..b14165ffbd9 100755 --- a/scripts/build-algolia.js +++ b/scripts/build-algolia.js @@ -11,9 +11,6 @@ const nue = []; const rawdata = fs.readFileSync('public/algolia.json'); const nodes = JSON.parse(rawdata); -console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&') -console.log(process.env) -console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&') nodes.forEach(node => { const dom = new JSDOM(node.content); const content = dom.window.document.body; //post content wrapped in a body tag @@ -83,10 +80,5 @@ nodes.forEach(node => { const merged = [...nodes, ...nue]; -// fs.writeFileSync('public/combined.algolia.json', JSON.stringify(merged)); -// process.exit(0); -atomicalgolia(process.env.ALGOLIA_INDEX_NAME, merged, (err, result) => { - if (err) throw err; - console.log(result); - process.exit(0); -}); +fs.writeFileSync('public/final.algolia.json', JSON.stringify(merged)); +process.exit(0); From bec9ff93238d00374eee95307591d5c022b170d9 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Tue, 10 Jul 2018 12:02:07 -0700 Subject: [PATCH 3/3] debugging --- gulpfile.babel.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 01d6fd4044f..f4066c85c15 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -28,6 +28,11 @@ process.on('uncaughtException', (err) => { console.log('Uncaught Exception, exiting', '\r\n', err); process.exit(1); }); + +console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&') +console.log(process.env) +console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&') + // -- gulp.task('dev', ['build-dev'], () => { gulp.start('init-watch');