Skip to content

Commit c6eb044

Browse files
feat(dist:Dockerfile): initial add dist Dockerfile
Add functionality to add Dockerfile to dist folder in the same way as the heroku Procfile is created No docker integration to build image Closes angular-fullstack#1531
1 parent 70d3117 commit c6eb044

File tree

5 files changed

+64
-7
lines changed

5 files changed

+64
-7
lines changed

Diff for: app/templates/Gruntfile(grunt).js

+5-4
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ module.exports = function (grunt) {
161161
},
162162
src: ['<%%= yeoman.server %>/**/*.{spec,integration}.js']
163163
},
164-
all: ['<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js'],
164+
all: ['<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock|app.constant).js'],
165165
test: {
166166
src: ['<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js']
167167
}
@@ -197,7 +197,7 @@ module.exports = function (grunt) {
197197
dot: true,
198198
src: [
199199
'.tmp',
200-
'<%%= yeoman.dist %>/!(.git*|.openshift|Procfile)**'
200+
'<%%= yeoman.dist %>/!(.git*|.openshift|Procfile|Dockerfile)**'
201201
]
202202
}]
203203
},
@@ -424,7 +424,8 @@ module.exports = function (grunt) {
424424
dest: '<%%= yeoman.dist %>',
425425
src: [
426426
'package.json',
427-
'<%%= yeoman.server %>/**/*'
427+
'<%%= yeoman.server %>/**/*',
428+
'!<%%= yeoman.server %>/config/local.env.sample.js'
428429
]
429430
}]
430431
},
@@ -636,7 +637,7 @@ module.exports = function (grunt) {
636637
files: [{
637638
expand: true,
638639
cwd: '<%%= yeoman.server %>',
639-
src: ['**/*.{js,json}'],
640+
src: ['**/*.js'],
640641
dest: '<%%= yeoman.dist %>/<%%= yeoman.server %>'
641642
}]
642643
}

Diff for: app/templates/gulpfile.babel(gulp).js

+9-3
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ gulp.task('transpile:server', () => {
312312
gulp.task('lint:scripts', cb => runSequence(['lint:scripts:client', 'lint:scripts:server'], cb));
313313

314314
gulp.task('lint:scripts:client', () => {
315-
return gulp.src(_.union(paths.client.scripts, _.map(paths.client.test, blob => '!' + blob)))
315+
return gulp.src(_.union(
316+
paths.client.scripts,
317+
_.map(paths.client.test, blob => '!' + blob),
318+
[`!${clientPath}/app/app.constant.<%= scriptExt %>`]
319+
))
316320
.pipe(lintClientScripts());
317321
});
318322

@@ -373,7 +377,9 @@ gulp.task('watch', () => {
373377
.pipe(plugins.livereload());
374378
});
375379

376-
plugins.watch(paths.client.views)
380+
plugins.watch(paths.client.views)<% if(filters.jade) { %>
381+
.pipe(plugins.jade())
382+
.pipe(gulp.dest('.tmp'))<% } %>
377383
.pipe(plugins.plumber())
378384
.pipe(plugins.livereload());
379385

@@ -497,7 +503,7 @@ gulp.task('build', cb => {
497503
cb);
498504
});
499505

500-
gulp.task('clean:dist', () => del([`${paths.dist}/!(.git*|.openshift|Procfile)**`], {dot: true}));
506+
gulp.task('clean:dist', () => del([`${paths.dist}/!(.git*|.openshift|Procfile|Dockerfile)**`], {dot: true}));
501507

502508
gulp.task('build:client', ['transpile:client', 'styles', 'html', 'constant'], () => {
503509
var manifest = gulp.src(`${paths.dist}/${clientPath}/assets/rev-manifest.json`);

Diff for: docker/USAGE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Description:
2+
Add a Dockerfile to the dist folder.
3+
4+
Example:
5+
yo angular-fullstack:docker
6+
7+
This will create:
8+
a dist folder with a Dockerfile in it

Diff for: docker/index.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
var util = require('util');
3+
var yeoman = require('yeoman-generator');
4+
var exec = require('child_process').exec;
5+
var chalk = require('chalk');
6+
var path = require('path');
7+
var s = require('underscore.string');
8+
9+
var Generator = module.exports = function Generator() {
10+
yeoman.generators.Base.apply(this, arguments);
11+
this.sourceRoot(path.join(__dirname, './templates'));
12+
this.filters = this.config.get('filters') || {};
13+
};
14+
15+
util.inherits(Generator, yeoman.generators.NamedBase);
16+
17+
Generator.prototype.copyDockerfile = function copyDockerfile() {
18+
if(this.abort) return;
19+
var done = this.async();
20+
this.log(chalk.bold('Creating Dockerfile'));
21+
this.copy('Dockerfile', 'dist/Dockerfile');
22+
this.conflicter.resolve(function (err) {
23+
done();
24+
});
25+
};
26+
27+
Generator.prototype.gruntBuild = function gruntBuild() {
28+
if(this.abort) return;
29+
var done = this.async();
30+
31+
this.log(chalk.bold('\nBuilding dist folder, please wait...'));
32+
var child = exec('grunt build', function (err, stdout) {
33+
done();
34+
}.bind(this));
35+
child.stdout.on('data', function(data) {
36+
this.log(data.toString());
37+
}.bind(this));
38+
};
39+
40+

Diff for: docker/templates/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM generatorangularfullstack/angular-fullstack-dist:3.3.0
2+

0 commit comments

Comments
 (0)