Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GradleでビルドしてDockerで配布する
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Hidetake Iwata
December 19, 2014
Technology
990
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GradleでビルドしてDockerで配布する
JGGUG大忘年会LT大会と、LondonのG*なカンファレンス行ってきた報告!+合宿の報告もあるよ!
https://jggug.doorkeeper.jp/events/17692
Hidetake Iwata
December 19, 2014
More Decks by Hidetake Iwata
See All by Hidetake Iwata
Rewrite Go error handling using AST transformation
int128
1
1.4k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.9k
認証の仕組みとclient-go credential plugin / authentication and client-go credential plugin
int128
7
8k
CLIでOAuth/OIDCを快適に利用する
int128
0
1k
AppEngine × Spring Boot × Kotlin
int128
0
170
いつものJIRA設定
int128
1
250
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
5k
本番環境のリリースを自動化した話
int128
0
860
Swagger × Spring Cloud
int128
0
150
Other Decks in Technology
See All in Technology
Essential architectural thinking (revised edition)
ufried
0
110
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
3
690
3つのアプローチで目指す チームを強くするAI駆動開発
thkt
0
150
会社説明資料
persolserverworks
0
9.7k
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
350
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
0
310
ai_cording_with_k8s_knowledge.pdf
mochizuki875
1
330
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
1
410
全人類(ほぼ)AWS Organizations の上でAWSを利用している、その世界を知る話
htan
1
130
freeeらしさをAIとともに作る / Creating the freee Experience with AI
ymrl
0
220
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
290
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
0
190
Featured
See All Featured
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
530
GraphQLとの向き合い方2022年版
quramy
50
15k
Designing for Timeless Needs
cassininazir
1
520
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Fireside Chat
paigeccino
43
4.1k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
560
Building an army of robots
kneath
307
47k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
400
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
700
ラッコキーワード サービス紹介資料
rakko
1
5.3M
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Transcript
Gradleでビルドして Dockerで配布する JGGUG LT 2014.12.19 @int128
@int128 https://github.com/int128
Gradle SSH Pluginの作者です https://gradle-ssh-plugin.github.io
アプリケーションの 提供と利用 について考える
リリース手順.xls この端末のEclipseで ビルドしたJARを 設定ファイルと一緒に ZIPで固めて ポータルサイトに アップしておいてね
使い方.txt ポータルサイトから ZIPをダウンロードして 適当な場所に解凍して java -jar hoge.jar を実行してください
つらい
提供しやすく利用しやすい アプリケーションの特徴 提供しやすいアプリケーションとは • 誰でも同じ方法でビルドできる • 環境に依存しない 利用しやすいアプリケーションとは • 簡単に入手できる
• 導入の手間がかからない • 誰でも同じ方法で実行できる
提供しやすく利用しやすい アプリケーションの特長 提供しやすいことのメリット • ニーズに合わせて早く提供できる • 計画や開発にリソースを集中できる (リアルJenkinsおじさん不要) 利用しやすいことのメリット •
ユーザに好印象を与える • 多くのユーザを獲得できる • 導入が面倒なアプリは損をしている
JVMベースの アプリケーション (Groovy, Scala, Java等) 固有の課題
JVMベースのアプリケーションの課題 提供側がつらいこと • コマンドラインツールを配布できるエコシステム がない(RubyGemsとかnpmとか) • シェルスクリプトやバッチの同梱が面倒 利用側がつらいこと • JVMのインストールが面倒
• JVMのデフォルト引数がいけてないので ヒープメモリの指定がほぼ必須
アプリケーションの提供と利用の形態 Webサービス ➔ 提供側はアプリをインフラにデプロイ ➔ 利用側はサービスにアクセス コマンドラインツールやWebアプリ ➔ 提供側はアプリをWeb上に公開 ➔
利用側はダウンロードして利用
アプリケーションの提供と利用に GradleやDockerを使う Webサービス ➔ 提供側はアプリをGradleでビルド ➔ 提供側はアプリをDockerでデプロイ ➔ 利用側はサービスにアクセス コマンドラインツールやWebアプリ
➔ 提供側はアプリをGradleでビルド ➔ 提供側はアプリをDocker Hubに公開 ➔ 利用側はDocker Hubから取得
Gradleでビルドして Dockerで配布する
Gradleのメリット 誰でも同じ方法でアプリケーションを ビルドできる • インストール不要でJVMがあれば動く (Gradle wrapper) • ./gradlew build
を叩くだけでアプリを ビルドできる • 必要なライブラリは自動的に取得
Dockerのメリット 誰でも同じ方法でアプリケーション一式を ビルド、配布、実行できる • docker build を叩くだけで イメージをビルドできる • docker
run を叩くだけで コンテナを実行できる • Docker HubやPrivate Registryで イメージを配布できる
Gradle + Docker のメリット 提供側のメリット • 誰でも同じ方法で アプリケーション一式をビルドできる • 統一的な基盤で、
アプリケーション一式を配布できる 利用側のメリット • 誰でも同じ方法で アプリケーションを実行できる
GradleでビルドしてDockerで配布 1. Gradleでアプリケーションをビルド 2. Dockerイメージを配布 3. ユーザはDockerコンテナを実行 Docker イメージ Docker
コンテナ アプリ OS/JVM アプリ OS/JVM 依存JARs ソースコード 設定ファイル 1. ビルド 2. 配布 3. 実行
Gradle Application Plugin アプリケーションの実行に必要なファイル群を生成 してくれるプラグイン • プロダクト本体 • 実行時の依存ライブラリ •
JVMを起動するシェルスクリプト • JVMを起動するバッチファイル ※Gradleに標準で含まれるプラグイン
plugins { id 'groovy' id 'application' } mainClassName = 'org.example.Main'
applicationDefaultJvmArgs = ['-Xmx512m'] アプリケーションを配置する ./gradlew installApp アプリケーションをZIPアーカイブに固める ./gradlew distZip Gradle Application Plugin の使い方 build.gradle
• build/install/groovy-ssh/bin ◦ groovy-ssh ◦ groovy-ssh.bat • build/install/groovy-ssh/lib ◦ groovy-all-2.3.6.jar
◦ groovy-ssh-SNAPSHOT.jar ◦ jna-3.4.0.jar ◦ jsch-0.1.51.jar ◦ ... ◦ platform-3.4.0.jar ◦ slf4j-api-1.7.7.jar Gradle Application Plugin の使用例 シェルスクリプト バッチファイル プロダクト本体 依存ライブラリ
Dockerイメージのビルド時に Gradleを実行する Javaイメージの上でGradleを実行して ビルド済みのアプリケーション一式を載せる Dockerイメージの構成例 ubuntu dockerfiles/java myapp Oracle JDK
7 ビルド済みの アプリケーション一式 OSの最小セット
Dockerイメージのビルド時に Gradleを実行する例 from dockerfile/java:oracle-java7 volume /usr/src/groovy-ssh copy . /usr/src/groovy-ssh run
cd /usr/src/groovy-ssh && \ ./gradlew -g .gradle installApp && \ cp -a build/install/groovy-ssh / workdir /groovy-ssh/bin entrypoint ["./groovy-ssh"] Dockerfile
Dockerを使うと Gradle SSH Pluginが 不要になる... oh...
まとめ JVMベースのアプリケーションを GradleでビルドしてDockerで配布する これにより、 • 提供側は誰でも同じ方法で アプリケーションをビルドできる • Docker Hubで簡単に配布できる
• 利用側は誰でも同じ方法で アプリケーションを実行できる