SlideShare a Scribd company logo
Ktor 

Fat Jar
—
(shengyou)
Kotlin Ktor
2020/10/18
—
• Developer Advocate
• Backend Developer
• Open Source Community Organizer
—
• Ktor
• Ktor
• Fat Jar
•
—
/ /
—
/ /
/
—
Fat Jar
Container
/
—
Fat Jar
Container
Shadow Plugin
—
// gradle.properties
shadow_version=5.1.0
// build.gradle
buildscript {
// ...
dependencies {
classpath "...:shadow:$shadow_version"
}
}
// ...
apply plugin: 'com.github.johnrengelman.shadow'
// ...
shadowJar {
manifest {
attributes 'Main-Class': mainClassName
}
}
Build
—
$ ./gradlew shadowJar
Run artifact
—
$ cd build/libs/
$ export PORT=* && java -jar *.jar
Provision
—
1. JVM
2. Nginx
—
$ apt update
$ apt upgrade
—
$ apt install vim curl 
wget git zip unzip 
software-properties-common
SDK
—
$ curl -s "https://get.sdkman.io" | bash
$ source "/root/.sdkman/bin/sdkman-init.sh"
$ sdk install java 11.0.7.hs-adpt
$ sdk install gradle
$ sdk install kotlin
$ java --version
$ gradle --version
Nginx
—
$ apt-add-repository ppa:nginx/development -y
$ apt-get install -y --allow-downgrades 
--allow-remove-essential 
--allow-change-held-packages 
nginx
Linux
—
1. App Linux
2.
3. SSL
Service
—
$ vim /etc/systemd/system/*.service
Serveice
—
[Unit]
Description=Ktor App
After=syslog.target
After=network.target[Service]
[Service]
ExecStart=/.../java -jar /.../*.jar
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=...
[Install]
WantedBy=multi-user.target
—
$ systemctl daemon-reload
$ systemctl start [service-name]
$ systemctl enable [service-name]
$ systemctl status [service-name]
Nginx
—
$ vim /etc/nginx/sites-available/[site-name]
Nginx
—
server {
listen 80;
listen [::]:80;
server_name ...;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
Nginx
—
$ ln -s /etc/nginx/sites-available/[site-name] 
/etc/nginx/sites-enabled/
$ nginx -t
$ systemctl restart nginx
SSL
—
$ add-apt-repository 
ppa:certbot/certbot
$ apt install python-certbot-nginx
$ systemctl reload nginx
$ certbot --nginx -d [site-url]
…
—
• /
• DNS
•
—
• Ktor Fat Jar
• JVM Nginx
• Ktor Linux Service
• Nginx Service SSL
—
• GCP - DevFest HK 2020
• Heroku -
• - (https://ktor.io/docs/deploy.html)
kotlin.tips
Kotlin
—
Shengyou Fan ( )
shengyou.fan@jetbrains.com
Q&A
—
Ktor
Fat Jar

More Related Content

PPTX
20110521 eightfold path and meditation2
 
PDF
以 Kotlin 快速打造 Mobile Backend
PDF
用 Kotlin 做自動化工具
PPTX
GIT, RVM, FIRST HEROKU APP
PPTX
Android build on windows
PDF
Front-end tools
PDF
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
PPTX
20150317 firefox os_studymtg_engver
20110521 eightfold path and meditation2
 
以 Kotlin 快速打造 Mobile Backend
用 Kotlin 做自動化工具
GIT, RVM, FIRST HEROKU APP
Android build on windows
Front-end tools
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
20150317 firefox os_studymtg_engver

Similar to Ktor 部署攻略 - 老派 Fat Jar 大法 (20)

PDF
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PDF
Challenges of container configuration
PDF
Android gradle-build-system-overview
PDF
Serverless Container with Source2Image
PDF
Serverless containers … with source-to-image
PDF
Working with the AOSP - Linaro Connect Asia 2013
PPTX
Rhodes mobile Framework
PDF
Container Days Boston - Kubernetes in production
PDF
Let Grunt do the work, focus on the fun!
PPTX
Single Page JavaScript WebApps... A Gradle Story
PDF
Bundling Client Side Assets
PDF
Instrumentación de entrega continua con Gitlab
PDF
DCSF19 Dockerfile Best Practices
PDF
Puppet at Opera Sofware - PuppetCamp Oslo 2013
PPTX
2018 RubyHACK: put git to work - increase the quality of your rails project...
PPTX
2018 the conf put git to work - increase the quality of your rails project...
PDF
Kotlin 一條龍 - 打造全平台應用
PPTX
Into to Docker (Central PA Java User Group - 8/14/2017)
PPTX
Google Cloud Build - Overview and Examples
PDF
5 Things I Wish I Knew About Gitlab CI
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
Challenges of container configuration
Android gradle-build-system-overview
Serverless Container with Source2Image
Serverless containers … with source-to-image
Working with the AOSP - Linaro Connect Asia 2013
Rhodes mobile Framework
Container Days Boston - Kubernetes in production
Let Grunt do the work, focus on the fun!
Single Page JavaScript WebApps... A Gradle Story
Bundling Client Side Assets
Instrumentación de entrega continua con Gitlab
DCSF19 Dockerfile Best Practices
Puppet at Opera Sofware - PuppetCamp Oslo 2013
2018 RubyHACK: put git to work - increase the quality of your rails project...
2018 the conf put git to work - increase the quality of your rails project...
Kotlin 一條龍 - 打造全平台應用
Into to Docker (Central PA Java User Group - 8/14/2017)
Google Cloud Build - Overview and Examples
5 Things I Wish I Knew About Gitlab CI
Ad

More from Shengyou Fan (20)

PDF
[JCConf 2024] Kotlin/Wasm:為 Kotlin 多平台帶來更多可能性
PDF
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
PDF
[JCConf 2023] 從 Kotlin Multiplatform 到 Compose Multiplatform:在多平台間輕鬆共用業務邏輯與 U...
PDF
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
PDF
[WebConf Taiwan 2023] 一份 Zend Engine 外帶!透過 Micro 讓一次打包、多處運行變得可能
PDF
How I make a podcast website using serverless technology in 2023
PDF
[Effective Kotlin 讀書會] 第八章 Efficient collection processing 導讀
PDF
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
PDF
[JCConf 2022] Compose for Desktop - 開發桌面軟體的新選擇
PDF
Using the Exposed SQL Framework to Manage Your Database
PDF
[COSCUP 2022] 讓黑畫面再次偉大 - 用 PHP 寫 CLI 工具
PDF
[COSCUP 2022] Kotlin Collection 遊樂園
PDF
初探 Kotlin Multiplatform
PDF
簡化 JVM 上雲 - 透過 Azure Spring Cloud 提升開發、發佈及服務監控效率
PDF
[PHP 也有 Day #64] PHP 升級指南
PDF
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
PDF
Composer 經典食譜
PDF
老派浪漫:用 Kotlin 寫 Command Line 工具
PDF
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
PDF
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
[JCConf 2024] Kotlin/Wasm:為 Kotlin 多平台帶來更多可能性
[GDG Kaohsiung DevFest 2023] 以 Compose 及 Kotlin Multiplatform 打造多平台應用程式
[JCConf 2023] 從 Kotlin Multiplatform 到 Compose Multiplatform:在多平台間輕鬆共用業務邏輯與 U...
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
[WebConf Taiwan 2023] 一份 Zend Engine 外帶!透過 Micro 讓一次打包、多處運行變得可能
How I make a podcast website using serverless technology in 2023
[Effective Kotlin 讀書會] 第八章 Efficient collection processing 導讀
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
[JCConf 2022] Compose for Desktop - 開發桌面軟體的新選擇
Using the Exposed SQL Framework to Manage Your Database
[COSCUP 2022] 讓黑畫面再次偉大 - 用 PHP 寫 CLI 工具
[COSCUP 2022] Kotlin Collection 遊樂園
初探 Kotlin Multiplatform
簡化 JVM 上雲 - 透過 Azure Spring Cloud 提升開發、發佈及服務監控效率
[PHP 也有 Day #64] PHP 升級指南
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
Composer 經典食譜
老派浪漫:用 Kotlin 寫 Command Line 工具
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
[Kotlin Serverless 工作坊] 單元 3 - 實作 JSON API
Ad

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Getting Started with Data Integration: FME Form 101
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
Network Security Unit 5.pdf for BCA BBA.
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Group 1 Presentation -Planning and Decision Making .pptx
Spectroscopy.pptx food analysis technology
Getting Started with Data Integration: FME Form 101
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MIND Revenue Release Quarter 2 2025 Press Release
Building Integrated photovoltaic BIPV_UPV.pdf
Assigned Numbers - 2025 - Bluetooth® Document
NewMind AI Weekly Chronicles - August'25-Week II
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction

Ktor 部署攻略 - 老派 Fat Jar 大法