Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

[WIP] initial attempt at a standalone version using docker-compose #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ build

# VIM Swap
.*.swp


# local stuff
config.local.js
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:10.15.3

# Create app directory
WORKDIR /opt/stackstorm/static/webui/st2flow

# get files
COPY . .

RUN cd /opt/stackstorm/static/webui && git clone https://github.com/StackStorm/st2web.git

# install dependencies
RUN npm install -g gulp-cli lerna yarn
RUN cd /opt/stackstorm/static/webui/st2web && lerna bootstrap
RUN ls /opt/stackstorm/static/webui/st2web


RUN cd /opt/stackstorm/static/webui/st2flow && lerna bootstrap
RUN ls /opt/stackstorm/static/webui/st2flow




# expose your ports
EXPOSE 3000

# start it up
CMD [ "gulp" ]
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.2'
services:
app:
build: .
ports:
- "3000:3000"
expose:
- 3000
volumes:
- .:/opt/stackstorm/static/webui/st2flow
- ./config.local.js:/opt/stackstorm/static/webui/st2web/config.js
- /opt/stackstorm/static/webui/st2flow/node_modules
- /opt/stackstorm/static/webui/st2web/node_modules
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
/* jshint node: true */
'use strict';

require('@stackstorm/st2-build');
require('./tasks');
160 changes: 160 additions & 0 deletions tasks/browserify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
// Copyright 2019 Extreme Networks, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const gulp = require('gulp');
const settings = require('./settings.json');
const plugins = require('gulp-load-plugins')(settings.plugins);
const path = require('path');
const fs = require('fs');

const _ = require('lodash');
const git = require('git-rev-sync');
const pkg = require(`${process.cwd()}/package.json`);
const es = require('event-stream');
const browserify = require('browserify');
const watchify = require('watchify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const pathmodify = require('pathmodify');
const cssExtract = require('css-extract');
const chalk = require('chalk');
const fancylog = require('fancy-log');

function buildHeader() {
const host = 'https://github.com/';
const commitURL = `${host + pkg.repository}/commit/${git.long()}`;

return `Built ${new Date().toISOString()} from ${commitURL}`;
}

function walk(dir) {
const pkgPath = path.join(dir, 'package.json');
if (fs.existsSync(pkgPath)) {
return require(pkgPath);
}

const nextDir = path.dirname(dir);

if (nextDir === dir) {
return false;
}

return walk(nextDir);
}

function overridePackage(overrides) {
return (rec) => {
const from = rec.id;
const to = overrides[from];

if (!to) {
return {};
}

const pkg = walk(path.dirname(rec.opts.filename));
if (pkg && pkg.name === to) {
return {
id: from,
};
}

return {
id: to,
};
};
}

function bundle(file, name) {
const customOpts = {
fullPaths: true,
entries: [ file ],
debug: true,
};
const opts = _.assign({}, watchify.args, customOpts);

const b = !global.watch ? browserify(opts) : watchify(browserify(opts), { poll: 100 })
.on('update', () => {
bundle(file, name)
.pipe(plugins.size({
showFiles: true,
}))
.pipe(plugins.size({
showFiles: true,
gzip: true,
}))
;
});

if (pkg.override) {
b
.plugin(pathmodify, {
mods: overridePackage(pkg.override),
});
}

fs.mkdir(settings.styles.dest, () => { /* noop */ });

b
.plugin(cssExtract, { out: path.join(settings.styles.dest, 'style.css')})
.on('log', fancylog)
;

return b.bundle()
.on('error', function (error) {
fancylog(
chalk.cyan('Browserify') + chalk.red(' found unhandled error:\n'),
error.toString()
);
this.emit('end');
})
.pipe(source(name))
.pipe(buffer())
.pipe(plugins.sourcemaps.init({ loadMaps: true }))
.pipe(plugins.header(`/* ${buildHeader()} */`))
.pipe(plugins.sourcemaps.write('./'))
.pipe(gulp.dest('js/'))
;
}

gulp.task('browserify', () => {
const tasks = _.map(settings.modules, bundle);

return es.merge.apply(null, tasks)
.pipe(plugins.size({
showFiles: true,
}))
.pipe(plugins.size({
showFiles: true,
gzip: true,
}))
;
});

gulp.task('watchify', () => {
global.watch = true;

const tasks = _.map(settings.modules, bundle);

return es.merge.apply(null, tasks)
.pipe(plugins.size({
showFiles: true,
}))
.pipe(plugins.size({
showFiles: true,
gzip: true,
}))
;
});
19 changes: 19 additions & 0 deletions tasks/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2019 Extreme Networks, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const gulp = require('gulp');

gulp.task('build', gulp.series([ 'lint', 'browserify' ]));
19 changes: 19 additions & 0 deletions tasks/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2019 Extreme Networks, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const gulp = require('gulp');

gulp.task('default', gulp.series([ 'lint', 'watch', 'serve' ]));
24 changes: 24 additions & 0 deletions tasks/font.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2019 Extreme Networks, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const gulp = require('gulp');
const fontelloUpdate = require('fontello-update');

gulp.task('font', () => fontelloUpdate({
config: 'fontello.json',
fonts: 'font',
css: 'font',
}));
23 changes: 23 additions & 0 deletions tasks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2019 Extreme Networks, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const gulp = require('gulp');
const fwdRef = require('undertaker-forward-reference');

gulp.registry(fwdRef());

const requireDir = require('require-dir');
module.exports = requireDir('./', { recurse: true });
25 changes: 25 additions & 0 deletions tasks/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2019 Extreme Networks, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const gulp = require('gulp');
const settings = require('./settings.json');
const plugins = require('gulp-load-plugins')(settings.plugins);

gulp.task('lint', () => gulp.src(settings.lint, { cwd: settings.dev })
.pipe(plugins.plumber())
.pipe(plugins.eslint())
.pipe(plugins.eslint.format())
);
Loading