go pro, inc. case study: dive into the details of our node.js applications
TRANSCRIPT
Dive into the details of our Node.js applicationsLevel: Intermediate - Advanced
All slides are available @
slideshare.net/heka1
Andrew Maxwell
About Me:
● GoPro, Inc.
● Frontend Software Technical Lead
● 10+ years in the industry
● I manage the Web-App team
Contact Info:
● Google+: Andrew Maxwell
● LinkedIn: Andrew Maxwell
● Twitter: @amaxwell02
● Github: amaxwell01
● Instagram: amaxwell01
● andrewcmaxwell.com
Gopro Web Applications
GoPro: Case Study
● Goals of our applications
● Development setup
● Coding process
● Problems & solutions
● What’s next?
Goals for our applications
Goals for our applications
1. Follow the Unix philosophy
“Do one thing and do it well”
2. All apps are isolated from each other and are only connected through the login application
Goals for our applications
3. All Node applications are based off of our web-base framework
Goals for our applications
4. All apps must run in docker
● Single docker image for all environments (local, QA, staging and production)
● Every deploy gets its own tagged image with code
Goals for our applications
5. All apps MUST be deployed independently
● No app should block one another from being deployed
● Move Fast
Goals for our applications
6. Easy roll backs thanks to every deploy getting its own tagged version of a docker image
● Send an update notice to our cluster to roll back to the previous tag
● Removing the impact on our customers
Goals for our applications
Goals for our applications
7. Follow rolling release train to ship consistently, but only what’s ready
Development setup
Development setupIsomorphic App Setup
Start from SCRATCH
● Start a new project
● Clone from web-base to the name of your new project
$git clone [gopro-web-base].git gopro-web-login
Development setup
● Hello World
Development setup
Development setup
Update our configuration files
● app-config.js
● gopro.json
● package.json
● docker-compose.yml
One command to run them all
Development setup
$MAKE
We can get you coding in 10 minutes:
$git clone gopro-web-login
$cd gopro-web-login
$make
Development setup
● $make install
○ Mapped to NPM install
● $make build
○ mapped to gulp build
■ runs webpack with node
● $make lint
○ gulp eslint
● $make test
○ Mapped to gulp test
■ runs Jest / Jasmine unit tests
● $make server
○ node babel.server.js
● $make dev
○ runs make install, make build, make
watch
● $make
○ make dev
All apps run with 7 simple commands:
Development setup
Build Process with Node and Gulp
Development setup
&
Quality and standards in our builds
Development setup
Watch files for changes
Development setup
Coding process
All components are react components
Lint our code
Coding process
Check docker
● Every time we make a change to our server setup, we make sure that we run our changes locally in docker
$docker-compose run
Coding process
Push the changes up to Github and fires off our build
1. All features get their own branch
2. Circle CI automatically kicks off our build process for the new branch
3. Circle CI creates a tags a new docker image with the built code
4. Each branch can be tested in isolation with a unique sub-domain
Coding process
Create pull requests
1. Create a new PR for the changes
a. Must be a single commit or as little of commits as possible
b. Must include the ticket number as the first part of the commit title
2. Circle CI run’s our build process and adds badges to the Github PR
3. Code is reviewed by team
4. Original developer merges their own code and close the PR
Coding process
Pro’s & Con’s
Pro’s of isomorphic applications:
● One language (JavaScript)
● Shared components
● Faster rendering time
● Less moving parts
● Easy deployments
● Fast development
● Better S.E.O
● Running similar, but not identical, API requests on the server/client
● Unit tests require some HTML to be tested (blurs the line of unit vs E2E test)
● Some routes set in Hapi, some in React Router
● Debugging API requests can be tricky depending on if it is done on the client,
the server, or both
● 2 forms of logging
Con’s of isomorphic applications:
Problems & Solutions
Memory leak on health checks
Node-debugger
Sever metric monitoring
Problems & Solutions:
Problems & Solutions:
Debugging API requests on the client / server
Set up better logging using Bunyan
Problems & Solutions:
Lib-sass not staying up to date with Node changes
Node.js foundation - All is well again
Problems & Solutions:
Moving fast and staying up to date with Node versions
NVM
Problems & Solutions:
30+ second startup times because Babel6 doesn’t play nice with NPM 2
Changed to a new version of Node.js with NPM 3
Problems & Solutions:
Building multiple apps at once and keeping them in sync
Set up Web-base, our internal “desired” collection of frameworks and configuration
Problems & Solutions:
100+ feature based deployments a day, leaving around unused docker images on server
A bi-hourly cleaner to remove unused docker images
What’s next?
1. Continue improving our web-base framework.
2. Improve feature-base branch development to work better with our API’s
3. Create a CLI-tool to help start new projects, add tests, etc.
4. More tests!
Let’s dive into code
Questions?
Thank You!
● https://gopro.com
● https://www.docker.com
● https://nodejs.org/en
● http://hapijs.com
● http://gulpjs.com
● https://github.com/dlmanning/gulp-sass
● http://eslint.org
● https://babeljs.io
● https://facebook.github.io/react
● https://webpack.github.io
● https://github.com/trentm/node-bunyan
Links: