Permalink
Browse files

Added docker support in project tools.

Added grunt 'dockerize' task.
Added automatic push to hub.docker.com after release through 'publish' task.
  • Loading branch information...
marcominetti committed Oct 1, 2015
1 parent c98ac2a commit 8f9868274763794681cffd87dd333c03d5696d25
Showing with 123 additions and 8 deletions.
  1. +1 −0 .dockerignore
  2. +1 −0 .gitignore
  3. +45 −0 dockerfile.in
  4. +74 −7 gruntfile.js
  5. +2 −1 package.json
View
@@ -0,0 +1 @@
+*
View
@@ -17,6 +17,7 @@
/dist/*
# Project and core development files
+/Dockerfile
/bin
/app
/config
View
@@ -0,0 +1,45 @@
+FROM ubuntu:@@UBUNTU
+MAINTAINER Marco Minetti <marco.minetti@novetica.org>
+
+RUN mv /bin/sh /bin/sh.backup && ln -s /bin/bash /bin/sh
+RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
+
+RUN apt-get update
+RUN apt-get -y dist-upgrade
+RUN apt-get -y install gcc make curl git python python-dev libssl-dev build-essential ca-certificates
+
+RUN apt-get clean
+RUN rm /var/lib/apt/lists/* -rf
+
+ENV NVM_DIR /usr/local/nvm
+ENV PROFILE /etc/bash.bashrc
+ENV NODE_VERSION @@NODE
+
+RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash \
+ && source $NVM_DIR/nvm.sh \
+ && nvm install $NODE_VERSION \
+ && nvm alias default $NODE_VERSION
+
+RUN echo -e "#!/bin/bash\n. /etc/bash.bashrc\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\"\nnode \$@" > /usr/local/bin/node
+RUN chmod +x /usr/local/bin/node
+
+RUN echo -e "#!/bin/bash\n. /etc/bash.bashrc\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\"\nnpm \$@" > /usr/local/bin/npm
+RUN chmod +x /usr/local/bin/npm
+
+RUN node -v
+RUN npm -v
+
+RUN npm install -g ljve.io@@@LJVE
+
+RUN echo -e "#!/bin/bash\n. /etc/bash.bashrc\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\"\nljve \$@" > /usr/local/bin/ljve
+RUN chmod +x /usr/local/bin/ljve
+
+WORKDIR /ljve/
+
+EXPOSE 8080 9090 9091 9092 9093
+
+ENTRYPOINT [ "/usr/local/bin/ljve" ]
+
+
+
+docker run -v $(pwd):/ljve/ -i -t ljveio/core:development run
View
@@ -4,6 +4,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-release');
+ grunt.loadNpmTasks('grunt-replace');
grunt.initConfig({
availabletasks: {
@@ -14,46 +15,68 @@ module.exports = function(grunt) {
'clean',
'test',
'build',
- 'release'
+ 'dockerize',
+ 'publish'
]
}
}
},
jscs: {
- src: "./"
+ src: './'
},
eslint: {
target: ['./']
},
shell: {
clean: {
- command: "node main.server.js _.clean",
+ command: 'node main.server.js _.clean',
options: {}
},
buildcore: {
- command: "node main.server.js _.build.core",
+ command: 'node main.server.js _.build.core',
options: {
execOptions: {
maxBuffer: 1024*1024
}
}
},
distcore: {
- command: "node main.server.js _.dist.core",
+ command: 'node main.server.js _.dist.core',
options: {}
},
buildcluster: {
- command: "node main.server.js _.build.cluster",
+ command: 'node main.server.js _.build.cluster',
options: {
execOptions: {
maxBuffer: 1024*1024
}
}
},
distcluster: {
- command: "node main.server.js _.dist.cluster",
+ command: 'node main.server.js _.dist.cluster',
+ options: {}
+ },
+ dockerinit: {
+ command: 'cp dockerfile.in Dockerfile',
options: {}
}
+ ,
+ dockerbuild: {
+ command: 'docker build -t ljveio/core:latest .',
+ options: {
+ execOptions: {
+ maxBuffer: 1024*1024
+ }
+ }
+ },
+ dockerpush: {
+ command: 'docker push ljveio/core:latest',
+ options: {
+ execOptions: {
+ maxBuffer: 1024*1024
+ }
+ }
+ }
},
release: {
options: {
@@ -70,11 +93,49 @@ module.exports = function(grunt) {
tagMessage: 'Tagged release <%= version %>.',
remote: 'public'
}
+ },
+ replace: {
+ dockerfile: {
+ options: {
+ patterns: [
+ {
+ match: 'UBUNTU',
+ replacement: 'latest'
+ },
+ {
+ match: 'NODE',
+ replacement: 'stable'
+ },
+ {
+ match: 'LJVE',
+ replacement: function(){
+ var fs = require('fs');
+ var path = require('path');
+ packagejson = JSON.parse(fs.readFileSync(path.join(process.cwd(),'package.json'), 'utf8'));
+ return packagejson.version;
+ }
+ },
+ ]
+ },
+ files: [
+ { expand: true,
+ flatten: true,
+ src: ['Dockerfile']
+ }
+ ]
+ }
}
});
grunt.registerTask('default', [ 'availabletasks' ]);
+ grunt.registerTask('publish', [
+ 'build',
+ 'release',
+ 'dockerize',
+ 'shell:dockerpush'
+ ]);
+
grunt.registerTask('clean', [
'shell:clean'
]);
@@ -92,4 +153,10 @@ module.exports = function(grunt) {
'shell:distcluster'
]);
+ grunt.registerTask('dockerize', [
+ 'shell:dockerinit',
+ 'replace:dockerfile',
+ 'shell:dockerbuild'
+ ]);
+
};
View
@@ -96,7 +96,8 @@
"grunt-jscs": "latest",
"grunt-eslint": "latest",
"grunt-shell": "latest",
- "grunt-release": "latest"
+ "grunt-release": "latest",
+ "grunt-replace": "latest"
},
"optionalDependencies": {
"sysconfx-next": "latest",

0 comments on commit 8f98682

Please sign in to comment.