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
PlayとHerokuでSPAを作ってみた
Search
masato
April 18, 2019
Technology
610
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PlayとHerokuでSPAを作ってみた
はてなブックマークのランキングが閲覧できるサービス「BukumaRanking」を作った
勉強がてらPlayとDockerでSPA作ってみたので、実装方法、苦労した点を共有
masato
April 18, 2019
More Decks by masato
See All by masato
関数型プログラミング実践入門を読んで
masato_deck
0
420
Other Decks in Technology
See All in Technology
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
6
4.9k
Metadata - Section 1: HTML Basics
mohab1
0
120
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
450
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
100
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
250
re:Invent初参加で変わったこと、2回目にやってみたいこと(JAWS-UG彩の国埼玉 #12)
mhrtech
2
220
AI時代のPRレビューにどう向き合うか?
kairim0
1
240
その Valkey 使いこなしていますか?
onk
PRO
5
1.5k
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
1
440
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
920
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
170
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
Building an army of robots
kneath
307
47k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
580
Automating Front-end Workflow
addyosmani
1369
210k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Transcript
PlayとHerokuでSPA のアプリ作ってみ た
概要 ❏ はてなブックマークのランキングが閲覧 できるサービス「BukumaRanking」を作っ た ❏ 勉強がてらPlayとDockerでSPA作ってみた ので、実装方法、苦労した点を共有 2
BukumaRanking ❏ 日別・週別・月別・年別・累計 3
BukumaRanking ❏ HotEntry(ブクマ数降順) 4
モチベーション - はてなブックマークが好き - 日間週間等の人気ランキングがほしい - 5
はてなブックマークの問題 - 人気順はできるが、全ブクマの検索はで きない仕様 - キーワードorタグorユーザー指定の検索 はできる 6
モチベーション - タグ検索で無理やり作る 7
SPA構成 8
全体構成 ❏ フロントエンド: ❏ VueJs2.5 ❏ Bulma ❏ サーバーサイド: ❏
Play2.6.2(Scala) ❏ 本番サーバー: ❏ Docker ❏ Heroku 9
構成(ローカル) 10 localhost:8 080 localhost:9000 1:index.html vue-routerで 切り替え 2: /api/**
はてなRSS 3: RSS取得
構成(本番) 11 index.html 1: /api以外のパス (/ranking/daily等) 2: /api/** はてなRSS 3:
RSS取得
Playですべてを配信する ❏ Index.htmlやjs等の静的ファイルの配信 先 ❏ ローカル:vue-cliのサーバー ❏ 本番:play ❏ buildしたファイルをpublicへ置く
❏ / …public/index.html ❏ /*path … /api等一部のパス以外すべて public/index.html ❏ Controllerの実装: 12
Docker化 13
HerokuでPlayのコンテナを作るには 1. DockerのBaseImage選択 (java系) 2. Heroku用のアプリ側ソース修正 3. Heroku用のDockerfile修正 4. Dockerイメージ作成
5. イメージをHerokuのクラウドにpush 14
DockerのBaseImage選択 (java系) ▣ adoptopenjdk/openjdk11:alpine-slim ❏ 247 MB ❏ https://k11i.biz/blog/2018/10/29/base-docke r-images-for-java11/
15
Heroku用のアプリ側ソース修正 ❏ PORTは可変で固定(9000等に)できない ❏ Heroku上で環境変数で定義されている$PORTをア プリ側に設定 ❏ (失敗)JAVA_OPTS="-Dhttp.port=$PORT" ❏ `heroku
config`でアプリの使用する環境 変数を設定 ❏ PLAY_APPLICATION_SECRETなど 16
Heroku用のDockerfile修正 ❏ sbt-native-packager (1.3.10)で設定 ❏ CMDが空コマンドなので消す ❏ ENTRYPOINTはHerokuだと使えない罠 ❏ CMDに変換
17
sbt-native-packager1.3.19の罠 ❏ Dockerのビルドで以下行でエラー ❏ useradd --system --create-home --uid 1001 --gid
0 demiourgos728 ❏ alphineだとuseraddが使えない(adduserはある) ❏ 時間かけすぎたのでひとまずバージョンダウン ❏ 1.3.19 → 1.3.10 18
イメージの作成とpush ❏ $ sbt "docker:publishLocal" ❏ imageを生成 ❏ $ docker
tag hatena:1.0 \ registry.heroku.com/<app-name>/web ❏ $ docker push registry.heroku.com/<app-name>/web ❏ $ heroku container:release web 19
まとめ ▣ 苦労した点 □ PlayをSPAで動かす方法わからない □ Docker化が地味に大変だった ▪ Heroku独特の設定でハマる ▪
sbt-native-packagerが一筋縄でいかない ▣ SPAの作り方とDocker化がわかってきた 20
参考 ❏ [ScalaアプリをDockerイメージ化してHerokuにデプロイした話 - Chatwork Creator's Note](https://creators-note.chatwork.com/entry/2017/11/24/1027 49) ❏ スライド:[Free
modern Powerpoint template or Google Slides theme with fresh colors](https://www.slidescarnival.com/desdemona-free-presenta tion-template/165) ❏ [Play2でのSPAコンテンツの配信の仕方 - Qiita](https://qiita.com/uryyyyyyy/items/0719dc4b25512b3d3e5f) 21