Top Banner
Node.js開発者のための Heroku Salesforce Developer Web セミナー [email protected] @sho7650 (Qiita/Twitter) 阿部 崇 (Takashi Abe) Platform Specialist
47

Node.js開発者のためのHeroku入門

Jan 22, 2018

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Node.js Heroku

    Salesforce Developer Web

    [email protected] @sho7650

    (Qiita/Twitter)

    (Takashi Abe) Platform Specialist

  • Forward-Looking Statements

    Statement under the Private Securities Litigation Reform Act of 1995:

    This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

    The risks and uncertainties referred to above include but are not limited to risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.

    Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

  • HerokuNode.js Heroku

    Node.js Github Heroku Salesforce

    Node.jsHeroku Node.js Web

  • Heroku/

    Node.js +Expresson Heroku

    HerokuDashboard

    Heroku Pipeline(CD)

    OK

  • (Takashi Abe) Platform Specialist (@sho7650) HW IT : Perfume/BABYMETAL/

  • Heroku

  • Web()

    ()()

    OS//

    Heroku 3

  • : Heroku

    DBMS

    OS

    DBMS

    OS

    IaaS (Infrastructure as a Service)

    DBMS

    OS

    SaaS (Software as a Service)

    /

    DBMS

    OS

    PaaS (Platform as a Service)

    24/365

    IaaS

  • :

    Dyno

    Dyno

    Data

    Add-ons

    Payments Email SMS Search Analytics Monitoring Logging

    Ruby Node.js Java Node.js Node.js Scala Clojure

    Postgres Redis Kafka

    Heroku

    The Twelve Factor App

  • :

    Git / Github

    Pipeline > >

    Fork

  • /

    Private Spaces DynoDataHeroku

    SLA

    Add-on

    Heroku Connect Salesforce

    Private Spaces

    Heroku Connect

    Postgres Heroku

    Salesforce

  • PaaS /

    1.0API0.2()

    Heroku PostgreSQL / SendGrid / Cloudinary

    Web(fork)

  • Node.jsHeroku

  • Node.js on Heroku : Heroku

    Heroku () git ()Heroku CLI

    Heroku git!

  • Heroku Heroku Sign up

    https://www.heroku.com/home

  • Heroku FREE ACCOUNT

  • Heroku Heroku Heroku CLI

    https://devcenter.heroku.com/articles/heroku-cli

  • Node.js+Expresson HerokuNode.js/WebHeroku

  • Heroku/Web git push !

    Heroku

    git clone

    heroku create

    :

    git push heroku logs

    150!?

  • ()

    $ git clone https://github.com/tabesfdc/heroku_nodejs_20170525.git

    Cloning into 'heroku_nodejs_20170525'... remote: Counting objects: 56, done. remote: Compressing objects: 100% (35/35), done. remote: Total 56 (delta 17), reused 52 (delta 15), pack-reused 0 Unpacking objects: 100% (56/56), done. $ cd ./heroku_nodejs_20170525/

    () cd

  • Heroku (Dyno) Heroku

    $ heroku create

    Creating app... done, shielded-escarpment-56633 https://calm-lowlands-14220.herokuapp.com/ | https://git.heroku.com/ shielded-escarpment-56633.git

    ()Heroku WebURL https:// shielded-escarpment-56633.herokuapp.com/

    heroku create Heroku

  • Heroku Addon hobby-dev Heroku Postgres

    $ heroku addons:create heroku-postgresql:hobby-dev

    Creating heroku-postgresql:hobby-dev on calm-lowlands-14220... free Database has been created and is available ! This database is empty. If upgrading, you can transfer ! data from another database with pg:copy Created postgresql-rugged-39577 as DATABASE_URL Use heroku addons:docs heroku-postgresql to view documentation

    () DB URL DATABASE_URL

  • !

    $ git remote v

    heroku https://git.heroku.com/shielded-escarpment-56633.git (fetch) heroku https://git.heroku.com/shielded-escarpment-56633.git (push) origin https://github.com/tabesfdc/heroku_nodejs_20170525.git (fetch) origin https://github.com/tabesfdc/heroku_nodejs_20170525.git (push)

    $ git push heroku master

    Counting objects: 140, done. Delta compression using up to 4 threads.

    : To https://git.heroku.com/shielded-escarpment-56633.git * [new branch] master -> master

    () heroku create git

  • $ heroku logs

    2017-05-24T06:27:43.003450+00:00 heroku[web.1]: Starting process with command `npm start` 2017-05-24T06:27:49.673347+00:00 app[web.1]: 2017-05-24T06:27:49.673389+00:00 app[web.1]: > [email protected] start /app 2017-05-24T06:27:49.673390+00:00 app[web.1]: > node ./bin/www 2017-05-24T06:27:49.673391+00:00 app[web.1]: 2017-05-24T06:27:50.442533+00:00 heroku[web.1]: State changed from starting to up

    ()

  • Rails rake db:migrate

    $ heroku run sequelize db:migrate

    Running sequelize db:migrate on shielded-escarpment-56633... up, run.8804 (Free) Sequelize [Node: 6.10.3, CLI: 2.7.0, ORM: 3.30.4] Loaded configuration file "config/config.json". Using environment "production". == 20170524051320-create-account: migrating ======= == 20170524051320-create-account: migrated (0.268s)

    () heroku run dyno Worker Dyno

  • Web

    $ heroku open

    heroku open Web! !

  • Heroku DashboardGUI

  • Heroku Dashboard Heroku Web

  • Heroku Dashboard: apps Heroku

    ()

  • Heroku Dashboard: OverviewHeroku

    Dyno

    Dyno

  • Heroku Dashboard: ResourcesDyno

    Dyno

    Dyno

  • Heroku Dashboard: Metrics

  • Heroku Dashboard: Access

  • Heroku Dashboard: SettingsHeroku

    buildpack

    SSL

    !

  • Heroku Pipelines + Pull requestContinious Delivery(CD)

    https://devcenter.heroku.com/articles/pipelines

    Pull Request !!

  • Heroku Button 1click Heroku deploy

    https://devcenter.heroku.com/articles/heroku-button

    1CLICK !!

  • : app.json Heroku Button Pipeline app.json

    { "name": "heroku-nodejs-0525", "scripts": { "postdeploy": " }, "env": { "APP_KEY": { "value": " } }, "formation": { }, "addons": [ "heroku-postgresql:hobby-dev ], buildpacks": [ { "url": "heroku/nodejs } ] }

    app.json

    ()

    buildpack

  • Node.js with Express

  • Node.js with Express Heroku

    PostgreSQL package.json Procfile Heroku

  • PostgreSQLHeroku PostgreSQL sqlite3

  • package.jsonnpm

    { "name": "heroku-nodejs-20170525", "version": "0.0.1", "private": true, "scripts": { "start": "node ./bin/www }, "dependencies": { "pg": "~6.2.2", "body-parser": "~1.17.1", "cookie-parser": "~1.4.3", "debug": "~2.6.3", "express": "~4.15.2", "jade": "~1.11.0", "morgan": "~1.8.1", "serve-favicon": "~2.4.2 } }

    Express

  • ProcfileNode.js Procfile

    web: npm index.js

    node.js

    Node.js Procfile npm start !

  • pg

    "production": { "use_env_variable": "DATABASE_URL, "dialect": "postgres" }

    sequelize

    var pg = require('pg'); app.get('/db', function (request, response) { pg.connect(process.env.DATABASE_URL, function(err, client, done) { client.query('SELECT * FROM test_table', function(err, result) { done(); if (err) { console.error(err); response.send("Error " + err); } else { response.render('pages/db', {results: result.rows} ); } }); }); });

    pg

    Node

  • DB

    heroku run sequelize db:migrate --env production -m

    sequelize Migration

  • Node.js ...

    TZ Asia/Tokyo

    PORT (process.env.PORT)

    port

  • Heroku

    Dyno 24+ 24

    Web 30

    Twelve Factor App(https://12factor.net/ja/)

    Heroku

    https://devcenter.heroku.com/articles/limits

  • Heroku

    Heroku

    Heroku Web GUIDashboard CLI

    git push