SlideShare a Scribd company logo
let swift(16)
Docker + Swift Server-Side
OSXDEV.orgByungwook Ahn
OSXDEV.orgWonseok Yang
1
2
Experienced
Device driver(windows, linux)
Media streaming
CDN
Docker
Letswift Conf. 2016 Speaker
Tensorflow-KR 2016 Speaker
PyCon Hongkong 2015 Speaker
PyCon Korea 2015 Speaker
3
Agenda
WWDC 2016 - swift session
Server-Side?
Swift backend framework
VirtualBox, Kitura, Docker
myFirstProject
Demo
Summary
4
WWDC 2016 - swift session
Swift
What’s New in Swift : https://developer.apple.com/videos/play/wwdc2016/402/
Client-Side
What’s New in Foundation for Swift : https://developer.apple.com/videos/play/wwdc2016/207/
Getting Started with Swift : https://developer.apple.com/videos/play/wwdc2016/404/
Introducing Swift Playgrounds : https://developer.apple.com/videos/play/wwdc2016/408/
Swift API Design Guidelines : https://developer.apple.com/videos/play/wwdc2016/403/
Understanding Swift Performance : https://developer.apple.com/videos/play/wwdc2016/416/
Concurrent Programming With GCD in Swift 3 : https://developer.apple.com/videos/play/
wwdc2016/720/
Using Store Kit for In-App Purchase wit Swift 3 : https://developer.apple.com/videos/play/
wwdc2016/702/
Server-Side
Going Server-side with Swift Open Source : https://developer.apple.com/videos/play/
wwdc2016/415/
Software Engineer
@red
5
Server-Side?
Backend Web Framework
Web Framework?
Ajax asynchronous Javascript and XML
MVC framework Model/View/Controller
i18n Internationalization ( ex:date … )
ORM Object Relational Mapping(RDB)
Testing framework Framework JUnit, Cedar…
Security Framework Spring Security(OAuth)
Template Framework Mustache
Caching Framework redis, Ehcache
6
Kitura Perfect
Hosted IBM perfect.org
latest version v0.20.0 v1.0.0
started date Feb 9, 2016 Oct 3, 2015
License Apache 2.0 Apache 2.0
MySQL O O
SQLite O O
Redis O O
HTTP URL routing O O
Parmeter Parsing O O
JSON O O
OAuth Kitura-Credentials -
Package/3rdParty Library Many ?
Swift backend framework
Most popular Swift backend framework : Zewo,Vapor…
let swift(16)
VirtualBox, Kitura, Docker
https://github.com/bwahn/letswift2016-conference
8
VirtualBox(vagrantfile)
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX_URL = 'https://cloud-images.ubuntu.com/vagrant/wily/current/wily-server-cloudimg-amd64-vagrant-
disk1.box'.freeze
SWIFT_PATH = 'https://swift.org/builds/development/ubuntu1510/swift-DEVELOPMENT-
SNAPSHOT-2016-06-06-a'.freeze
SWIFT_DIRECTORY = 'swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a-ubuntu15.10'.freeze
SWIFT_FILE = "#{SWIFT_DIRECTORY}.tar.gz".freeze
SWIFT_HOME = "/home/vagrant/#{SWIFT_DIRECTORY}".freeze
LIBDISPATCH_URL = '-b experimental/foundation https://github.com/apple/swift-corelibs-libdispatch'.freeze
KITURA_URL = 'https://github.com/IBM-Swift/Kitura.git'.freeze
KITURA_BRANCH = 'master'.freeze
Vagrant.configure(2) do |config|
config.vm.box = BOX_URL
config.vm.network 'forwarded_port', guest: 8090, host: 8090
Swift 3.0
For Restful-APIs
9
KITURA master
###
# 1. Install compiler, autotools
sudo apt-get --assume-yes install clang
sudo apt-get --assume-yes install autoconf libtool pkg-config
# 2. Install dtrace (to generate provider.h)
sudo apt-get --assume-yes install systemtap-sdt-dev
# 3. Install libdispatch pre-reqs
sudo apt-get --assume-yes install libblocksruntime-dev libkqueue-dev libpthread-
workqueue-dev libbsd-dev
# 4. Kitura packages
sudo apt-get --assume-yes install libhttp-parser-dev libcurl4-openssl-dev libhiredis-dev
Install packages
10
11
### Download and install Kitura
git clone #{KITURA_URL} -b #{KITURA_BRANCH}
cd Kitura
swift build -Xcc -fblocks
cd ..
$ vagrant up
let swift(16)
myFirstProject
13
$ vagrant ssh
vagrant@vagrant-ubuntu-wily-64: $ mkdir myFirstProject
vagrant@vagrant-ubuntu-wily-64: $ cd myFirstProject
vagrant@vagrant-ubuntu-wily-64: $ swift package init
14
$ vi package.swift
import PackageDescription
let package = Package(
name: "myFirstProject",
dependencies: [
.Package(url: "https://github.com/IBM-Swift/Kitura.git",
majorVersion: 0, minor: 20)
])
15
$ vi Sources/main.swift
import Kitura
let router = Router()
router.get("/") {
request, response, next in
response.send("Hello, World!")
next()
}
Kitura.addHTTPServer(onPort: 8090, with: router)
Kitura.run()
$ swift build -Xcc -fblocks
$ ./build/debug/myFirstProject
let swift(16)
For Docker
For Docker build
Run a letswift-api server
17
18
Docker build
$ git clone https://github.com/bwahn/
letswift2016-conference.git
$ docker build -t swift-api .
Docker run
$ docker run -d -p 8090:8090 --name api
swift-api:latest
image(swift-api:latest)
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
swift-api latest 829e110bd520 3 hours ago 1.524 GB
ibmcom/kitura-ubuntu latest 20cb1052cd2e 2 weeks ago 1.524 GB
ibmcom/swift-ubuntu latest b4daffd2bbaf 2 weeks ago 1.233 GB
Virtual Box VM - Ubuntu
$ docker run -d -p 8090 --name api1 swift-api:latest
$ docker run -d -p 8090 --name api2 swift-api:latest
$ docker run -d -p 8090 --name api3 swift-api:latest
…
…
..
macOS
port
8090:8090
? => scale up
$ docker-compose
19
let swift(16)
Demo : Introduction
“I Hate Objective-C” Application
Client : Swift 2.2 ( Cocoa-
touch)
Server : Swift 3 ( Kitura)
21
Architecture
MySQL
Cloud End-Point
swift backend
swift backend
swift backend
Google Container cluster
Swift App
22
Dev/Prod Environment
Virtual Box VM - Ubuntu
(Swift - backend)
google container registry
Swift - Client
Google Cloud Platform
swift backend
swift backend
swift backend
MySQL
24
==================================
Description : get a number of vote
Request: Verb: GET URL: http://letswift-api:8090/vote
Response: HTTP code: 200
Body:
{
"objective-c": 100,
"swift": 100
}
==================================
Description : Increase a vote
Request: Verb: PUT URL: http://letswift-api:8090/votes/objectivec_voted
Request: Verb: PUT URL: http://letswift-api:8090/votes/swift_voted
Response: HTTP code: 200
let swift(16)
Let’s vote!
25
26
let swift(16)

More Related Content

What's hot (20)

PDF
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
Ruoshi Ling
 
PPTX
OpenDaylight Developer Experience 2.0
Michael Vorburger
 
PPTX
Container sig#1 ansible-container
Naoya Hashimoto
 
PDF
Managing dependencies with gradle
Liviu Tudor
 
PDF
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Yoshifumi Kawai
 
PDF
PuppetConf 2016: Building Nano Server Images with Puppet and DSC – Michael Sm...
Puppet
 
PDF
Golang workshop
Victor S. Recio
 
PDF
PuppetConf 2016: Docker, Mesos, Kubernetes and...Puppet? Don't Panic! – Deep...
Puppet
 
PDF
Супер быстрая автоматизация тестирования на iOS
SQALab
 
PDF
手把手帶你學Docker 03042017
Paul Chao
 
PDF
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
Puppet
 
PDF
Docker & PHP - Practical use case
rjsmelo
 
PDF
時代在變 Docker 要會:台北 Docker 一日入門篇
Philip Zheng
 
PPTX
Going native with less coupling: Dependency Injection in C++
Daniele Pallastrelli
 
PDF
Dessi docker kubernetes paas cloud
Massimiliano Dessì
 
PPT
Build service with_docker_in_90mins
Larry Cai
 
PPTX
Start tracking your ruby infrastructure
Sergiy Kukunin
 
PDF
Gradle in 45min
Schalk Cronjé
 
PPTX
Vagrant
Denys Kurets
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
Ruoshi Ling
 
OpenDaylight Developer Experience 2.0
Michael Vorburger
 
Container sig#1 ansible-container
Naoya Hashimoto
 
Managing dependencies with gradle
Liviu Tudor
 
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Yoshifumi Kawai
 
PuppetConf 2016: Building Nano Server Images with Puppet and DSC – Michael Sm...
Puppet
 
Golang workshop
Victor S. Recio
 
PuppetConf 2016: Docker, Mesos, Kubernetes and...Puppet? Don't Panic! – Deep...
Puppet
 
Супер быстрая автоматизация тестирования на iOS
SQALab
 
手把手帶你學Docker 03042017
Paul Chao
 
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
Puppet
 
Docker & PHP - Practical use case
rjsmelo
 
時代在變 Docker 要會:台北 Docker 一日入門篇
Philip Zheng
 
Going native with less coupling: Dependency Injection in C++
Daniele Pallastrelli
 
Dessi docker kubernetes paas cloud
Massimiliano Dessì
 
Build service with_docker_in_90mins
Larry Cai
 
Start tracking your ruby infrastructure
Sergiy Kukunin
 
Gradle in 45min
Schalk Cronjé
 
Vagrant
Denys Kurets
 

Viewers also liked (9)

PDF
안드로이드 개발자를 위한 스위프트
병한 유
 
PDF
Swift and Xcode8
Hyuk Hur
 
PDF
Letswift Swift 3.0
Sehyun Park
 
PDF
Swift package manager
성관 윤
 
PDF
Do swift: Swift 무작정 해보기
YoonBong Steve Kim
 
PDF
스위프트 성능 이해하기
Yongha Yoo
 
PDF
Protocol Oriented Programming in Swift
SeongGyu Jo
 
PDF
Swift internals
Jung Kim
 
PDF
LetSwift RxSwift 시작하기
Wanbok Choi
 
안드로이드 개발자를 위한 스위프트
병한 유
 
Swift and Xcode8
Hyuk Hur
 
Letswift Swift 3.0
Sehyun Park
 
Swift package manager
성관 윤
 
Do swift: Swift 무작정 해보기
YoonBong Steve Kim
 
스위프트 성능 이해하기
Yongha Yoo
 
Protocol Oriented Programming in Swift
SeongGyu Jo
 
Swift internals
Jung Kim
 
LetSwift RxSwift 시작하기
Wanbok Choi
 
Ad

Similar to Swift server-side-let swift2016 (20)

PDF
GDGSCL - Docker a jeho provoz v Heroku a AWS
Ladislav Prskavec
 
PDF
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
PDF
Preparation study of_docker - (MOSG)
Soshi Nemoto
 
ODP
Docker engine - Indroduc
Al Gifari
 
PPTX
PHP on Heroku: Deploying and Scaling Apps in the Cloud
Salesforce Developers
 
PPTX
Blockchain Software for Hardware: The Canaan AvalonMiner Open Source Embedded...
Mike Qin
 
PDF
Docker module 1
Liang Bo
 
PDF
Developing and Deploying PHP with Docker
Patrick Mizer
 
PDF
Docker to the Rescue of an Ops Team
Rachid Zarouali
 
PDF
Docker to the Rescue of an Ops Team
Docker, Inc.
 
PDF
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
RapidValue
 
PDF
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Jian-Hong Pan
 
PPTX
Rasperry Pi and TI CC2650 IPv6 border router
Nikolaos Monios
 
PDF
Build and run embedded apps faster from qt creator with docker
Qt
 
PPTX
Webinar: Building Embedded Applications from QtCreator with Docker
Burkhard Stubert
 
PDF
Software Quality Assurance Tooling - Wintersession 2024
Henry Schreiner
 
PDF
Chicago Docker Meetup Presentation - Mediafly
Mediafly
 
PPTX
Introduction to Docker
Nissan Dookeran
 
PDF
BBL Premiers pas avec Docker
kanedafromparis
 
GDGSCL - Docker a jeho provoz v Heroku a AWS
Ladislav Prskavec
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Preparation study of_docker - (MOSG)
Soshi Nemoto
 
Docker engine - Indroduc
Al Gifari
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
Salesforce Developers
 
Blockchain Software for Hardware: The Canaan AvalonMiner Open Source Embedded...
Mike Qin
 
Docker module 1
Liang Bo
 
Developing and Deploying PHP with Docker
Patrick Mizer
 
Docker to the Rescue of an Ops Team
Rachid Zarouali
 
Docker to the Rescue of an Ops Team
Docker, Inc.
 
AWS EC2 Ubuntu Instance - Step-by-Step Deployment Guide
RapidValue
 
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Jian-Hong Pan
 
Rasperry Pi and TI CC2650 IPv6 border router
Nikolaos Monios
 
Build and run embedded apps faster from qt creator with docker
Qt
 
Webinar: Building Embedded Applications from QtCreator with Docker
Burkhard Stubert
 
Software Quality Assurance Tooling - Wintersession 2024
Henry Schreiner
 
Chicago Docker Meetup Presentation - Mediafly
Mediafly
 
Introduction to Docker
Nissan Dookeran
 
BBL Premiers pas avec Docker
kanedafromparis
 
Ad

More from Eric Ahn (15)

PDF
Tensorflow and python : fault detection system - PyCon Taiwan 2017
Eric Ahn
 
PDF
Docker remote-api
Eric Ahn
 
PDF
Docker deploy
Eric Ahn
 
PDF
Tensorflow in Docker
Eric Ahn
 
PDF
Docker command
Eric Ahn
 
PDF
High perforance-browse-networking-2015-bwahn
Eric Ahn
 
PDF
Cdn gslb-20151209
Eric Ahn
 
PDF
Keep it simple web development stack
Eric Ahn
 
PDF
Py conkr 20150829_docker-python
Eric Ahn
 
PDF
Http capturing
Eric Ahn
 
PDF
Apache module-201511
Eric Ahn
 
PDF
Spring rest-doc-2015-11
Eric Ahn
 
PDF
Py conkr 20150829_docker-python
Eric Ahn
 
PDF
CORS review
Eric Ahn
 
PPTX
Docker build #1
Eric Ahn
 
Tensorflow and python : fault detection system - PyCon Taiwan 2017
Eric Ahn
 
Docker remote-api
Eric Ahn
 
Docker deploy
Eric Ahn
 
Tensorflow in Docker
Eric Ahn
 
Docker command
Eric Ahn
 
High perforance-browse-networking-2015-bwahn
Eric Ahn
 
Cdn gslb-20151209
Eric Ahn
 
Keep it simple web development stack
Eric Ahn
 
Py conkr 20150829_docker-python
Eric Ahn
 
Http capturing
Eric Ahn
 
Apache module-201511
Eric Ahn
 
Spring rest-doc-2015-11
Eric Ahn
 
Py conkr 20150829_docker-python
Eric Ahn
 
CORS review
Eric Ahn
 
Docker build #1
Eric Ahn
 

Recently uploaded (20)

PPTX
西班牙武康大学毕业证书{UCAMOfferUCAM成绩单水印}原版制作
Taqyea
 
PDF
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
PPTX
一比一原版(LaTech毕业证)路易斯安那理工大学毕业证如何办理
Taqyea
 
PPTX
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
PPT
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
DOCX
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
PPTX
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
PPTX
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
PPTX
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
PPT
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
PPTX
原版西班牙莱昂大学毕业证(León毕业证书)如何办理
Taqyea
 
PDF
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
PPTX
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
PPTX
一比一原版(SUNY-Albany毕业证)纽约州立大学奥尔巴尼分校毕业证如何办理
Taqyea
 
PPTX
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
PPTX
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
PDF
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
PPTX
PE introd.pptxfrgfgfdgfdgfgrtretrt44t444
nepmithibai2024
 
PPT
introductio to computers by arthur janry
RamananMuthukrishnan
 
PPT
introduction to networking with basics coverage
RamananMuthukrishnan
 
西班牙武康大学毕业证书{UCAMOfferUCAM成绩单水印}原版制作
Taqyea
 
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
一比一原版(LaTech毕业证)路易斯安那理工大学毕业证如何办理
Taqyea
 
L1A Season 1 Guide made by A hegy Eng Grammar fixed
toszolder91
 
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
原版西班牙莱昂大学毕业证(León毕业证书)如何办理
Taqyea
 
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
一比一原版(SUNY-Albany毕业证)纽约州立大学奥尔巴尼分校毕业证如何办理
Taqyea
 
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
PE introd.pptxfrgfgfdgfdgfgrtretrt44t444
nepmithibai2024
 
introductio to computers by arthur janry
RamananMuthukrishnan
 
introduction to networking with basics coverage
RamananMuthukrishnan
 

Swift server-side-let swift2016

  • 1. let swift(16) Docker + Swift Server-Side OSXDEV.orgByungwook Ahn OSXDEV.orgWonseok Yang 1
  • 2. 2 Experienced Device driver(windows, linux) Media streaming CDN Docker Letswift Conf. 2016 Speaker Tensorflow-KR 2016 Speaker PyCon Hongkong 2015 Speaker PyCon Korea 2015 Speaker
  • 3. 3
  • 4. Agenda WWDC 2016 - swift session Server-Side? Swift backend framework VirtualBox, Kitura, Docker myFirstProject Demo Summary 4
  • 5. WWDC 2016 - swift session Swift What’s New in Swift : https://developer.apple.com/videos/play/wwdc2016/402/ Client-Side What’s New in Foundation for Swift : https://developer.apple.com/videos/play/wwdc2016/207/ Getting Started with Swift : https://developer.apple.com/videos/play/wwdc2016/404/ Introducing Swift Playgrounds : https://developer.apple.com/videos/play/wwdc2016/408/ Swift API Design Guidelines : https://developer.apple.com/videos/play/wwdc2016/403/ Understanding Swift Performance : https://developer.apple.com/videos/play/wwdc2016/416/ Concurrent Programming With GCD in Swift 3 : https://developer.apple.com/videos/play/ wwdc2016/720/ Using Store Kit for In-App Purchase wit Swift 3 : https://developer.apple.com/videos/play/ wwdc2016/702/ Server-Side Going Server-side with Swift Open Source : https://developer.apple.com/videos/play/ wwdc2016/415/ Software Engineer @red 5
  • 6. Server-Side? Backend Web Framework Web Framework? Ajax asynchronous Javascript and XML MVC framework Model/View/Controller i18n Internationalization ( ex:date … ) ORM Object Relational Mapping(RDB) Testing framework Framework JUnit, Cedar… Security Framework Spring Security(OAuth) Template Framework Mustache Caching Framework redis, Ehcache 6
  • 7. Kitura Perfect Hosted IBM perfect.org latest version v0.20.0 v1.0.0 started date Feb 9, 2016 Oct 3, 2015 License Apache 2.0 Apache 2.0 MySQL O O SQLite O O Redis O O HTTP URL routing O O Parmeter Parsing O O JSON O O OAuth Kitura-Credentials - Package/3rdParty Library Many ? Swift backend framework Most popular Swift backend framework : Zewo,Vapor…
  • 8. let swift(16) VirtualBox, Kitura, Docker https://github.com/bwahn/letswift2016-conference 8
  • 9. VirtualBox(vagrantfile) # -*- mode: ruby -*- # vi: set ft=ruby : BOX_URL = 'https://cloud-images.ubuntu.com/vagrant/wily/current/wily-server-cloudimg-amd64-vagrant- disk1.box'.freeze SWIFT_PATH = 'https://swift.org/builds/development/ubuntu1510/swift-DEVELOPMENT- SNAPSHOT-2016-06-06-a'.freeze SWIFT_DIRECTORY = 'swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a-ubuntu15.10'.freeze SWIFT_FILE = "#{SWIFT_DIRECTORY}.tar.gz".freeze SWIFT_HOME = "/home/vagrant/#{SWIFT_DIRECTORY}".freeze LIBDISPATCH_URL = '-b experimental/foundation https://github.com/apple/swift-corelibs-libdispatch'.freeze KITURA_URL = 'https://github.com/IBM-Swift/Kitura.git'.freeze KITURA_BRANCH = 'master'.freeze Vagrant.configure(2) do |config| config.vm.box = BOX_URL config.vm.network 'forwarded_port', guest: 8090, host: 8090 Swift 3.0 For Restful-APIs 9 KITURA master
  • 10. ### # 1. Install compiler, autotools sudo apt-get --assume-yes install clang sudo apt-get --assume-yes install autoconf libtool pkg-config # 2. Install dtrace (to generate provider.h) sudo apt-get --assume-yes install systemtap-sdt-dev # 3. Install libdispatch pre-reqs sudo apt-get --assume-yes install libblocksruntime-dev libkqueue-dev libpthread- workqueue-dev libbsd-dev # 4. Kitura packages sudo apt-get --assume-yes install libhttp-parser-dev libcurl4-openssl-dev libhiredis-dev Install packages 10
  • 11. 11 ### Download and install Kitura git clone #{KITURA_URL} -b #{KITURA_BRANCH} cd Kitura swift build -Xcc -fblocks cd .. $ vagrant up
  • 13. 13 $ vagrant ssh vagrant@vagrant-ubuntu-wily-64: $ mkdir myFirstProject vagrant@vagrant-ubuntu-wily-64: $ cd myFirstProject vagrant@vagrant-ubuntu-wily-64: $ swift package init
  • 14. 14 $ vi package.swift import PackageDescription let package = Package( name: "myFirstProject", dependencies: [ .Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 0, minor: 20) ])
  • 15. 15 $ vi Sources/main.swift import Kitura let router = Router() router.get("/") { request, response, next in response.send("Hello, World!") next() } Kitura.addHTTPServer(onPort: 8090, with: router) Kitura.run() $ swift build -Xcc -fblocks $ ./build/debug/myFirstProject
  • 17. For Docker build Run a letswift-api server 17
  • 18. 18 Docker build $ git clone https://github.com/bwahn/ letswift2016-conference.git $ docker build -t swift-api . Docker run $ docker run -d -p 8090:8090 --name api swift-api:latest image(swift-api:latest) $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE swift-api latest 829e110bd520 3 hours ago 1.524 GB ibmcom/kitura-ubuntu latest 20cb1052cd2e 2 weeks ago 1.524 GB ibmcom/swift-ubuntu latest b4daffd2bbaf 2 weeks ago 1.233 GB
  • 19. Virtual Box VM - Ubuntu $ docker run -d -p 8090 --name api1 swift-api:latest $ docker run -d -p 8090 --name api2 swift-api:latest $ docker run -d -p 8090 --name api3 swift-api:latest … … .. macOS port 8090:8090 ? => scale up $ docker-compose 19
  • 20. let swift(16) Demo : Introduction
  • 21. “I Hate Objective-C” Application Client : Swift 2.2 ( Cocoa- touch) Server : Swift 3 ( Kitura) 21
  • 22. Architecture MySQL Cloud End-Point swift backend swift backend swift backend Google Container cluster Swift App 22
  • 23. Dev/Prod Environment Virtual Box VM - Ubuntu (Swift - backend) google container registry Swift - Client Google Cloud Platform swift backend swift backend swift backend MySQL
  • 24. 24 ================================== Description : get a number of vote Request: Verb: GET URL: http://letswift-api:8090/vote Response: HTTP code: 200 Body: { "objective-c": 100, "swift": 100 } ================================== Description : Increase a vote Request: Verb: PUT URL: http://letswift-api:8090/votes/objectivec_voted Request: Verb: PUT URL: http://letswift-api:8090/votes/swift_voted Response: HTTP code: 200