Skip to content

Instantly share code, notes, and snippets.

@marcusgadbem
Last active August 29, 2015 14:16
Show Gist options
  • Save marcusgadbem/4de3410632ed5c34d49d to your computer and use it in GitHub Desktop.
Save marcusgadbem/4de3410632ed5c34d49d to your computer and use it in GitHub Desktop.
UMRUM - Azkfile
/**
* Documentation: http://docs.azk.io/Azkfile.js
*/
// Adds the systems that shape your system
systems({
umrum: {
// Dependent systems
depends: ["redis", "mongodb"],
// More images: http://images.azk.io
// image: {"docker": "node:0.10"},
image: {"docker": "dockerfile/nodejs-bower-grunt"},
// Steps to execute before running instances
provision: [
"npm install",
],
workdir: "/azk/#{manifest.dir}",
shell: "/bin/bash",
command: "grunt server",
wait: {"retry": 20, "timeout": 10000},
mounts: {
'/azk/#{manifest.dir}': path(".", { vbox: true } ),
},
scalable: {"default": 1},
http: {
domains: [ "#{system.name}.#{azk.default_domain}" ]
},
ports: {
http: "8000"
},
envs: {
// set instances variables
NODE_ENV: "dev",
NODE_PORT: "8000",
NODE_IP: "0.0.0.0",
UMRUM_SESSION_KEY: "umrum-secret",
GITHUB_ID: "d9f4d009c90281dc9794",
GITHUB_SECRET: "620a4c620fc24d47d46ae1dfb086a067635934d1",
GITHUB_CALLBACK: "http://umrum.dev.azk.io/auth/github/callback"
}
},
redis: {
image: { docker: "dockerfile/redis" },
scalable: false,
ports: {
data: "6379/tcp",
},
export_envs: {
REDIS_HOST: "redis://#{net.host}:#{net.port.data}/#{manifest.dir}",
REDIS_PORT: "6379"
},
mounts: {
'/data' : persistent('redis'),
},
},
mongodb: {
image: { docker: "dockerfile/mongodb" },
command: 'mongod --rest --httpinterface',
scalable: false,
ports: {
http: "28017",
},
http: {
domains: [ "#{manifest.dir}-#{system.name}.#{azk.default_domain}" ],
},
mounts: {
'/data/db': persistent('mongodb'),
},
export_envs: {
MONGO_URI: "mongodb://#{net.host}:#{net.port[27017]}/umrum_development",
},
}
});
/* globals module */
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
uglify: {
options: {
banner: '<%= banner %>'
},
core: {
options: {
sourceMap: true,
sourceMapName: 'public/js/core.js.map'
},
files: {
'public/js/core.min.js': [
'bower_modules/modernizr/modernizr.js',
'bower_modules/jquery/jquery.js',
]
}
},
site: {
options: {
sourceMap: true,
sourceMapName: 'public/js/site.js.map'
},
files: {
'public/js/site.min.js': [
'src/js/plugins/*.js',
'bower_modules/bootstrap/bootstrap.js',
'src/js/app/landing-page.js',
'src/js/app/chart.js'
]
}
},
application: {
options: {
sourceMap: true,
sourceMapName: 'public/js/application.js.map'
},
files: {
'public/js/application.min.js': [
'bower_modules/react/react.min.js',
'compiled_jsx/components/*.js',
]
}
}
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
browser: true,
globals: {
jQuery: true,
require: true,
module: true,
exports: true,
process: true,
console: true,
React: true
}
},
gruntfile: {
src: 'Gruntfile.js'
},
lib_test: {
src: [
'src/js/*.js',
'server.js',
'app/routes/*.js',
'config/**/*.js',
'tests/**/*.js'
]
}
},
less: {
production: {
options: {
cleancss: true,
compress: true,
},
files: {
'public/css/main.min.css': ['.less_compile/bootstrap.less'],
'public/css/site.min.css': ['.less_compile/site.less'],
'public/css/admin.min.css': ['.less_compile/admin.less']
}
}
},
autoprefixer: {
dist: {
options: {
browsers: ['last 2 versions', '> 10%', 'ie 8']
},
files: {
'public/css/main.min.css': ['public/css/main.min.css'],
'public/css/site.min.css': ['public/css/site.min.css'],
'public/css/admin.min.css': ['public/css/admin.min.css']
}
}
},
copy: {
imgs: {
expand: true,
cwd: 'src/img/',
src: '**',
dest: 'public/img'
},
fontawesome: {
files: [
{
expand: true,
cwd: 'bower_modules/fontawesome/fonts/',
src: '*',
dest: 'public/fonts'
},
{
expand: true,
cwd: 'bower_modules/fontawesome/less/',
src: '*',
dest: '.less_compile/font-awesome/'
},
]
},
bootstrapLess: {
files: [
{
expand: true,
cwd: 'bower_modules/bootstrap/',
src: '*.less',
dest: '.less_compile'
},
{
expand: true,
cwd: 'src/less/',
src: '**',
dest: '.less_compile'
}
]
}
},
react: {
compile: {
files: [
{
expand: true,
cwd: 'app/src',
src: ['**/*.jsx'],
dest: 'compiled_jsx',
ext: '.js'
}
]
}
},
bower: {
install: {
options: {
install: true,
cleanup: true,
verbose: false,
targetDir: './bower_modules'
}
}
},
mochacli: {
files: 'tests/',
options: {
reporter: 'spec',
recursive: true,
env: {
NODE_ENV: "test",
MONGO_URI: "mongodb://test:test123@ds053778.mongolab.com:53778/umrum-test",
NODE_PORT: "8000",
NODE_IP: "0.0.0.0",
GITHUB_ID: "SOME_GITHUB_ID",
GITHUB_SECRET: "SOME_GITHU_SECRET",
GITHUB_CALLBACK: "http://localhost:8000/auth/github/callback"
}
}
},
nodemon: {
dev: {
script: 'server.js',
options: {
ext: '*',
watch: ['app', 'src'],
env: {
NODE_ENV: "dev",
},
callback: function (nodemon) {
nodemon.on('log', function (e) {
grunt.log.writeln(e.colour);
});
nodemon.on('restart', function () {
grunt.log.subhead('Running compile task ... ');
grunt.util.spawn({
grunt: true,
args: ['_compile'],
}, function(err, result) {
grunt.log.debug(result.toString());
if (err || result.code !== 0) {
grunt.log.write('Error while compiling')
.error()
.error(err);
}
grunt.log.subhead('Compile task: \u001b[32mOK\u001B[0m');
});
});
}
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-mocha-cli');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-bower-installer');
grunt.loadNpmTasks('grunt-react');
// private tasks
grunt.registerTask('_minjs', ['react', 'uglify']);
grunt.registerTask('_lessc', ['copy:bootstrapLess', 'less', 'autoprefixer']);
grunt.registerTask('_compile', ['copy-static', '_lessc', '_minjs']);
grunt.registerTask('minjs', ['bower:install', '_minjs']);
grunt.registerTask('mincss', ['bower:install', '_lessc']);
grunt.registerTask('copy-static', ['copy:imgs', 'copy:fontawesome']);
grunt.registerTask('compile', ['bower:install', '_compile']);
grunt.registerTask('unittest', ['jshint', 'mochacli']);
//grunt.registerTask('server', ['compile', 'nodemon:dev']);
grunt.registerTask('server', ['nodemon:dev'])
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment