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.

E02ac480d0b92ec00e660be464d35c8d?s=128

Iheanyi Ekechukwu

June 28, 2016
Tweet

Transcript

  1. 4.
  2. 5.
  3. 6.
  4. 14.
  5. 17.
  6. 29.

    STEP TWO Manually deploy a Fastboot application, taking note of

    each action. (Provisioning, Deployment, etc.)
  7. 41.
  8. 45.
  9. 48.
  10. 53.
  11. 54.

    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, };
  12. 55.

    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); })
  13. 58.
  14. 59.

    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; },
  15. 60.

    willUpload: function(context) { var npmInstallTask = new NPMInstallTask({ log: this.log.bind(this),

    distDir: context.distDir }); return npmInstallTask.run() // more code down here }
  16. 61.

    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(); }); }); },
  17. 65.

    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
  18. 66.

    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… });
  19. 69.

    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; } } }
  20. 70.

    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… }
  21. 71.

    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); }); }); }
  22. 73.
  23. 75.
  24. 76.

    g

  25. 77.
  26. 89.
  27. 90.

    + ?

  28. 91.