Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ember.js, DevOps, and You - Wicked Good Ember 2016

Ember.js, DevOps, and You - Wicked Good Ember 2016

My talk on DevOps and Ember.js given at Wicked Good Ember 2016.

Iheanyi Ekechukwu

June 28, 2016
Tweet

More Decks by Iheanyi Ekechukwu

Other Decks in Programming

Transcript

  1. STEP TWO Manually deploy a Fastboot application, taking note of

    each action. (Provisioning, Deployment, etc.)
  2. this.conn = new SSHClient(); this.sshConfig = { host: config.ipAddress, port:

    22, username: config.dropletUsername, privateKey: require('fs').readFileSync(config.privateKeyPath), password: config.dropletPassword, passphrase: config.passphrase, };
  3. willUpload: function() { var conn = this.conn; conn.on('ready', () =>

    { conn.exec(‘sudo apt-get update -y; sudo apt-get upgrade -y; sudo apt-get install -y nginx gcc build- essential; rm /etc/nginx/sites-enabled/default', (err, stream) => { if (err) throw err; stream.on('data', (data) => { this.log('STDOUT: ' + data); }).on('end', (data) => { resolve(); }); }) }).connect(this.sshConfig); })
  4. configure: function() { //… this.scpConfig = { host: config.ipAddress, port:

    22, username: process.env.DROPLET_USERNAME || 'root', privateKey: require('fs').readFileSync(process.env.PRIVATE_KEY_DIR), password: process.env.DROPLET_PASSWORD, passphrase: process.env.PASSPHRASE, path: '/etc/nginx/sites-enabled/ember-app' }; this.scpClient = SCPClient; },
  5. willUpload: function(context) { var npmInstallTask = new NPMInstallTask({ log: this.log.bind(this),

    distDir: context.distDir }); return npmInstallTask.run() // more code down here }
  6. upload: function(context) { this.log('Uploading assets to the droplet!'); var scpClient

    = this.scpClient; return new Promise((resolve, reject) => { scpClient.scp(context.distDir, this.scpConfig, (err) => { if (err) { throw err; } //… return resolve(); }); }); },
  7. description "A job file for starting up the Fastboot service

    for Ember." author "Iheanyi Ekechukwu" start on filesystem or runlevel [2345] stop on shutdown pre-start script npm install -g ember-fastboot-server echo "Starting Fastboot server" >> /var/log/fastboot.log end script script export HOME echo $$ > /var/run/fastboot.pid exec ember-fastboot /etc/nginx/sites-enabled/ember-app >> /var/log/fastboot.log 2>&1 end script pre-stop script rm /var/run/fastboot.pid echo "Fastboot Server Stopping" >> /var/log/fastboot.log end script
  8. didUpload: function(context) { // other code…upload fast boot fileClient.upload('./node_modules/ember-cli- deploy-digitalocean/templates/fastboot.conf',

    '/ etc/init/fastboot.conf', err => { if (err) { this.log(err, {color: 'red'}); throw err; } // other code… });
  9. http { include /etc/nginx/mime.types*; default_type application/octet-stream; sendfile on; tcp_nopush on;

    tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; server { listen 80; root /etc/nginx/sites-enabled/ember-app; index index.html index.html; server_name localhost; location / { index index.html; proxy_pass http://127.0.0.1:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; } location ~ \.(ttf|ttc|otf|eot|woff|font.css|css)$ { add_header Access-Control-Allow-Origin "*"; } location /assets { autoindex on; } } }
  10. didUpload: function(context) { // upload nginx conf, other code left

    out fileClient.upload('./node_modules/ember-cli-deploy-digitalocean/ templates/nginx.conf', '/etc/nginx/nginx.conf', (err) => { if (err) { this.log(err); throw err; } return resolve(); }); // other code… }
  11. didUpload: function(context) { // restart nginx and fastboot service, other

    code left out conn.exec("sudo service nginx restart; sudo service fastboot restart;", (err, stream) => { if (err) throw err; stream.on('data', (data) => { this.log('STDOUT: ' + data); }).on('end', (data) => { this.log("We're in business!"); return resolve(); }).stderr.on('data', (data) => { this.log('STDERR: ' + data); }); }); }
  12. g

  13. + ?