Skip to content

Commit

Permalink
* Added dockerignore file to ignore node_modules
Browse files Browse the repository at this point in the history
   * Created gulp task to run docker with mongo service
  • Loading branch information
olegsu committed Oct 14, 2016
1 parent aab8406 commit 72df7c9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/*
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ RUN apt-get install -y nodejs nodejs-legacy npm
RUN apt-get clean
RUN npm install -g npm
RUN npm install --global gulp
COPY ./package.json /src/

RUN cd src && npm install
COPY ./package.json /src/
RUN cd /src && npm install

COPY . /src

WORKDIR src/
WORKDIR /src/

CMD ["gulp", "serve"]
CMD ["gulp", "serve:docker"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ services:
build: .
image: web
ports:
- 3000:3000
- 3001:3000
mongo:
image: mongo
28 changes: 28 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ gulp.task('env:all', () => {
vars: localConfig
});
});
gulp.task('env:docker', () => {
let localConfig;
try {
localConfig = require(`./${serverPath}/config/local.env.docker`);
} catch (e) {
localConfig = {};
}
plugins.env({
vars: localConfig
});
});
gulp.task('env:test', () => {
plugins.env({
vars: {NODE_ENV: 'test'}
Expand Down Expand Up @@ -350,6 +361,23 @@ gulp.task('serve', cb => {
);
});

gulp.task('serve:docker', cb => {
runSequence(
[
'clean:tmp',
'lint:scripts',
'inject',
'copy:fonts:dev',
'env:all',
'env:docker'
],
// 'webpack:dev',
['start:server', 'start:client'],
'watch',
cb
);
});

gulp.task('serve:debug', cb => {
runSequence(
[
Expand Down
2 changes: 1 addition & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import config from './config/environment';
import http from 'http';

// Connect to MongoDB
mongoose.connect('mongo', config.mongo.options);
mongoose.connect(config.mongo.uri, config.mongo.options);
mongoose.connection.on('error', function(err) {
console.log("test");
console.error('MongoDB connection error: ' + err , config.mongo.uri);
Expand Down
3 changes: 3 additions & 0 deletions server/config/local.env.docker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
MONGO_DOCKER: 'mongo'
}
2 changes: 1 addition & 1 deletion server/config/local.env.sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module.exports = {
DOMAIN: 'http://localhost:9000',
SESSION_SECRET: 'b7beet-secret',

// Control debug level for modules using visionmedia/debug
DEBUG: ''
};

0 comments on commit 72df7c9

Please sign in to comment.