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

Vapor プロジェクトの開発に使えそうなツールの紹介

Yutaka
December 19, 2016

Vapor プロジェクトの開発に使えそうなツールの紹介

Tokyo Server-Side Swift Meetup #5 2016.12.19 多鹿豊

Yutaka

December 19, 2016
Tweet

More Decks by Yutaka

Other Decks in Technology

Transcript

  1. gulp-vapor 導入前 1. vapor build コマンド 2. vapor run コマンド

    □ → localhost でプロジェクトのサーバー起動 3. ブラウザで動作確認 4. コード編集(保存) 5. vaporを殺す 6. 1に戻る
  2. セットアップ # gulpのインストール $ npm install -g gulp # プロジェクト直下でnpm

    init $ cd /path/to/your/vapor/project $ npm init # gulp-vaporをインストール $ npm install --save-dev gulp $ npm install --save-dev gulp-vapor
  3. gulpfile.js 'use strict'; var gulp = require('gulp'); var vapor =

    require('gulp-vapor'); vapor.config.commands.build = 'vapor build'; gulp.task('vapor:start', vapor.start); gulp.task('vapor:reload', vapor.reload); gulp.task('watch', function() { var target = [ './Sources/**/*', './Resources/**/*' ]; gulp.watch(target, ['vapor:reload']); }); gulp.task('default', ['vapor:start', 'watch']);
  4. gulp-vapor 導入後 1. gulp コマンド □ → localhost でプロジェクトのサーバー起動 2.

    ブラウザで動作確認 3. コード編集(保存) □ → gulp-vapor が保存を検知してbuild→reload 4. 2に戻る
  5. Flock概要 ◦ Swift製 ◦ Capistranoライクなデプロイツール ◦ Vapor, Kitura, Perfect, Zewo

    といった主要フ レームワークのデプロイに対応 https://github.com/jakeheis/Flock
  6. セットアップ # brewでインストール $ brew install jakeheis/repo/flock # Vaporプロジェクト直下で初期化 $

    cd /path/to/your/project $ flock --init • .flock/ • Flockfile • Config/deploy/ といったファイル・ディレクトリが作られ る
  7. セットアップ { "dependencies" : [ { "url" : "https://github.com/jakeheis/Flock", "version":

    "0.1.1" }, { "url" : "https://github.com/jakeheis/VaporFlock", "version": "0.0.4" } ] } Config/deploy/FlockDependencies.json
  8. セットアップ import Flock import VaporFlock Flock.use(Flock.Tools) Flock.use(Flock.Deploy) Flock.use(Flock.Vapor) Flock.configure(.always, with:

    Always()) // Located at config/deploy/Always.swift Flock.configure(.env("production"), with: Production()) // Located at config/deploy/Production.swift Flock.configure(.env("staging"), with: Staging()) // Located at config/deploy/Staging.swift Flock.run() Flockfile
  9. セットアップ import Flock import VaporFlock Flock.use(Flock.Tools) Flock.use(Flock.Deploy) Flock.use(Flock.Vapor) Flock.configure(.always, with:

    Always()) // Located at config/deploy/Always.swift Flock.configure(.env("production"), with: Production()) // Located at config/deploy/Production.swift Flock.configure(.env("staging"), with: Staging()) // Located at config/deploy/Staging.swift Flock.run() Flockfile 共通の設定
  10. セットアップ import Flock import VaporFlock Flock.use(Flock.Tools) Flock.use(Flock.Deploy) Flock.use(Flock.Vapor) Flock.configure(.always, with:

    Always()) // Located at config/deploy/Always.swift Flock.configure(.env("production"), with: Production()) // Located at config/deploy/Production.swift Flock.configure(.env("staging"), with: Staging()) // Located at config/deploy/Staging.swift Flock.run() Flockfile production環境 の設定
  11. セットアップ import Flock import VaporFlock Flock.use(Flock.Tools) Flock.use(Flock.Deploy) Flock.use(Flock.Vapor) Flock.configure(.always, with:

    Always()) // Located at config/deploy/Always.swift Flock.configure(.env("production"), with: Production()) // Located at config/deploy/Production.swift Flock.configure(.env("staging"), with: Staging()) // Located at config/deploy/Staging.swift Flock.run() Flockfile staging環境
  12. セットアップ import Flock import VaporFlock Flock.use(Flock.Tools) Flock.use(Flock.Deploy) Flock.use(Flock.Vapor) Flock.configure(.always, with:

    Always()) // Located at config/deploy/Always.swift Flock.configure(.env("production"), with: Production()) // Located at config/deploy/Production.swift Flock.configure(.env("staging"), with: Staging()) // Located at config/deploy/Staging.swift Flock.run() Flockfile # 環境を追加する $ flock --add-env <env>
  13. dependencies { "dependencies" : [ { "url" : "https://github.com/jakeheis/Flock", "version":

    "0.1.1" }, { "url" : "https://github.com/jakeheis/VaporFlock", "version": "0.0.4" } ] } Config/deploy/FlockDependencies.json
  14. dependencies { "dependencies" : [ { "url" : "https://github.com/jakeheis/Flock", "version":

    "0.1.1" }, { "url" : "https://github.com/jakeheis/VaporFlock", "version": "0.0.3" } ] } Config/deploy/FlockDependencies.json
  15. dependencies { "dependencies" : [ { "url" : "https://github.com/jakeheis/Flock", "version":

    "0.1.1" }, { "url" : "https://github.com/jakeheis/VaporFlock", "version": "0.0.3" } ] } Config/deploy/FlockDependencies.json
  16. dependencies { "dependencies" : [ { "url" : "https://github.com/jakeheis/Flock", "version":

    "0.1.1" }, { "url" : "https://github.com/jakeheis/VaporFlock", "version": "0.0.3" } ] } Config/deploy/FlockDependencies.json VaporFlock 0.0.3 は Flock 0.0.x に依存しているため、 バージョンの食い違いが起こ る
  17. セットアップ import Flock import VaporFlock Flock.use(Flock.Tools) Flock.use(Flock.Deploy) Flock.use(Flock.Vapor) Flock.configure(.always, with:

    Always()) // Located at config/deploy/Always.swift Flock.configure(.env("production"), with: Production()) // Located at config/deploy/Production.swift Flock.configure(.env("staging"), with: Staging()) // Located at config/deploy/Staging.swift Flock.run() Flockfile 共通の設定
  18. セットアップ import Flock import VaporFlock Flock.use(Flock.Tools) Flock.use(Flock.Deploy) Flock.use(Flock.Vapor) Flock.configure(.always, with:

    Always()) // Located at config/deploy/Always.swift Flock.configure(.env("production"), with: Production()) // Located at config/deploy/Production.swift Flock.configure(.env("staging"), with: Staging()) // Located at config/deploy/Staging.swift Flock.run() Flockfile production環境 の設定
  19. Config/deploy /Production.swift ◦ 当初 vagrant で試していた時に vagrant ユー ザーを設定 ◦

    → supervisor の installができず... apt-get -qq install supervisor E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?