├── .gitignore ├── Gruntfile.js ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | var pkg = require('./package.json'); 2 | 3 | module.exports = function (grunt) { 4 | 5 | /** 6 | * Initialize config. 7 | */ 8 | 9 | grunt.initConfig({ 10 | shipit: { 11 | options: { 12 | // Project will be build in this directory. 13 | workspace: '/tmp/hello-world-workspace', 14 | 15 | // Project will be deployed in this directory. 16 | deployTo: '/usr/src/hello-world', 17 | 18 | // Repository url. 19 | repositoryUrl: pkg.repository.url, 20 | 21 | // This files will not be transfered. 22 | ignores: ['.git', 'node_modules'], 23 | 24 | // Number of release to keep (for rollback). 25 | keepReleases: 3 26 | }, 27 | 28 | // Staging environment. 29 | staging: { 30 | servers: ['my-remote-server.com'] 31 | } 32 | } 33 | }); 34 | 35 | /** 36 | * Load shipit task. 37 | */ 38 | 39 | grunt.loadNpmTasks('grunt-shipit'); 40 | 41 | /** 42 | * Start project on the remote server. 43 | */ 44 | 45 | grunt.registerTask('start', function () { 46 | var done = this.async(); 47 | var current = grunt.config('shipit.options.deployTo') + '/current'; 48 | grunt.shipit.remote('cd ' + current + ' && npm start', done); 49 | }); 50 | 51 | /** 52 | * Run start task after deployment. 53 | */ 54 | 55 | grunt.shipit.on('published', function () { 56 | grunt.task.run(['start']); 57 | }); 58 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hello-world 2 | 3 | Demo project for Shipit tutorial. 4 | 5 | ## Set up remote server 6 | 7 | Create the remote user: 8 | 9 | ``` 10 | useradd deploy -m 11 | ``` 12 | 13 | Enable ssh with our authorized key: 14 | 15 | ``` 16 | mkdir /home/deploy/.ssh 17 | cat my_id_rsa.pub >> /home/deploy/.ssh/authorized_keys 18 | chown -R deploy:deploy /home/deploy/.ssh 19 | chmod 700 /home/deploy/.ssh 20 | chmod 600 /home/deploy/.ssh/authorized_keys 21 | ``` 22 | 23 | Create the deploy directory: 24 | 25 | ``` 26 | mkdir -p /usr/src/hello-world 27 | chown deploy:deploy /usr/src/hello-world 28 | ``` -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | console.log('hello world!'); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shipit-tutorial", 3 | "version": "0.0.0", 4 | "description": "Shipit tutorial.", 5 | "main": "index.js", 6 | "private": true, 7 | "scripts": { 8 | "start": "node index" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/neoziro/shipit-tutorial.git" 13 | }, 14 | "license": "MIT", 15 | "devDependencies": { 16 | "grunt": "^0.4.5", 17 | "grunt-shipit": "^0.3.4" 18 | } 19 | } 20 | --------------------------------------------------------------------------------