Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ember.js, DevOps, and You - NPM Camp 2016
Search
Iheanyi Ekechukwu
July 30, 2016
Programming
0
380
Ember.js, DevOps, and You - NPM Camp 2016
My talk on Ember.js, DevOps, and You and lessons learned from building a Ember-CLI-Deploy plugin.
Iheanyi Ekechukwu
July 30, 2016
Tweet
Share
More Decks by Iheanyi Ekechukwu
See All by Iheanyi Ekechukwu
Building a Canary Testing Framework
iheanyi
0
480
gRPC and Protobufs - JSCamp Romania
iheanyi
0
260
Ember.js, DevOps, and You - MadisonRuby 2016
iheanyi
0
220
Ember.js, DevOps, and You - Wicked Good Ember 2016
iheanyi
1
750
Intro to Ember.js and Ember-CLI - ThunderPlainsConf 2015
iheanyi
0
240
Intro to Ember.js and Ember-CLI - Front Porch 2015
iheanyi
0
450
Ember.js and Ember-CLI
iheanyi
5
530
Other Decks in Programming
See All in Programming
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
170
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.1k
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.3k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
440
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
110
Sidekiqで実現する 長時間非同期処理の中断と再開 / Pausing and Resuming Long-Running Asynchronous Jobs with Sidekiq
hypermkt
6
3k
Realtime API 入門
riofujimon
0
140
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
480
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
5
6.3k
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
420
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
480
僕がつくった48個のWebサービス達
yusukebe
20
17k
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
A Tale of Four Properties
chriscoyier
156
23k
Code Reviewing Like a Champion
maltzj
520
39k
Embracing the Ebb and Flow
colly
84
4.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
360
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
2k
Gamification - CAS2011
davidbonilla
80
5k
Writing Fast Ruby
sferik
627
61k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
What's in a price? How to price your products and services
michaelherold
243
12k
How to Ace a Technical Interview
jacobian
276
23k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
7
560
Transcript
Ember.js, DevOps, and You Iheanyi Ekechukwu NPM Camp 2016
Iheanyi Ekechukwu Software Engineer @ DigitalOcean @kwuchu
Defining DevOps What exactly is DevOps?
DevOps?
None
DevOps.
Development + Operations
DevOps is deploying.
DevOps is provisioning.
DevOps is versioning.
DevOps is complicated.
Automation is
Ember.js and DevOps What do Ember.js and DevOps have to
do with one another?
None
Ember-CLI-Deploy Plugins
An Ember-CLI-Deploy Plugin can implement up to 11 hooks
None
So, it doesn’t just deploy.
Ember-CLI-Deploy can provision.
Ember-CLI-Deploy can build.
Ember-CLI-Deploy can deploy.
Ember-CLI-Deploy can manage releases.
Ember-CLI-Deploy
Ember-CLI-DevOps
Building a Plugin
Create the Ember addon and install the Ember-CLI-Deploy base plugin.
STEP ONE
ember addon ember-cli-deploy-digitalocean
cd ember-cli-deploy-digitalocean npm install ember-cli-deploy-plugin --save
STEP TWO Manually deploy a Fastboot application, taking note of
each action. (Provisioning, Deployment, etc.)
Let’s go through the steps.
Create a Droplet.
SSH into the droplet.
Install Nginx, Node, NPM, and Ember-Fastboot-Server on droplet
On local machine, build the Fastboot application.
SCP the built Ember application onto the droplet
On droplet, go to the uploaded app and run the
Fastboot application.
Configure Nginx to proxy over the Fastboot’s server’s port and
serve static assets.
Reload Nginx.
And you’re done.
STEP THREE Translate each recorded step into code. (Automation)
None
Automation Problems and Solutions
PROBLEM How do I create a droplet for the user?
SOLUTION Use DigitalOcean’s API and create an Ember command that
creates the droplet.
None
export DO_ACCESS_TOKEN=<token>
ember do:provision
None
PROBLEM Installing all software dependencies on the droplet. (Provisioning)
WITHOUT FASTBOOT One package dependency. Web Server (NGINX) serves the
static assets.
WITH FASTBOOT More dependencies. It’s not only NGINX. We now
need Node, NPM, and Fastboot.
SOLUTION DigitalOcean Images and execution of commands via Node SSH2.
None
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, };
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); })
PROBLEM How do I build my Ember application and get
it onto the droplet?
SOLUTION Use ember-cli-deploy-build to build the application, NPM install dependencies,
then SCP files onto the droplet.
None
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; },
willUpload: function(context) { var npmInstallTask = new NPMInstallTask({ log: this.log.bind(this),
distDir: context.distDir }); return npmInstallTask.run() // more code down here }
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(); }); }); },
context.distDir
PROBLEM What if my droplet restarts and kills the Fastboot
server?
SOLUTION Create a Fastboot Upstart Service on the droplet.
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
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… });
PROBLEM How do I get the application up and served
up to the user?
SOLUTION Upload a custom NGINX config and restart everything.
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; } } }
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… }
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); }); }); }
And we’re done automating.
None
One small NPM trick that makes building deploy plugins easier…
None
g
None
ember-cli-deploy-digitalocean (github.com/iheanyi/ember-cli-deploy- digitalocean)
Plugin Limitations
Deploys limited to one droplet.
Provisioning tasks get re-run unnecessarily.
No controlled release management.
Old Fastboot Serving Logic
Ideas for Future Enhancements
Zero Downtime Deployments
SSL Support?
Semantic Versioning (semantic-release)
The Future of DevOps?
None
+ ?
None
Thanks to… @tomdale @lukemelia @davidpett @digitalocean and others!
Thank you. @kwuchu