Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ソースコードを快適に引き継いでいくためにやりたいこと/jtf2021w-f5-hassaku-...
Search
hassaku63
January 24, 2021
Programming
1
1.3k
ソースコードを快適に引き継いでいくためにやりたいこと/jtf2021w-f5-hassaku-building-development-environment-with-docker-and-vscode
July Tech Festa 2021 Winter - Session F5
https://techfesta.connpass.com/event/193966/
hassaku63
January 24, 2021
Tweet
Share
More Decks by hassaku63
See All by hassaku63
成果のためのコミュニケーション - 語彙を育てよう -/communication-for-good-outcome-developing-vocabulary
hassaku63
5
250
AWS re:Invent 2023 ML/AI x SaaS セッション振り返り/saas-eng-meetup-6_hassaku63
hassaku63
0
170
202310_社内LT/20231012_lighting_talk
hassaku63
0
54
CDK Day 2023 - Configure cross-account deployment using CDK
hassaku63
0
1.1k
CDK 座談会企画 2023-07 - CDK のメリットを再発掘してみよう
hassaku63
0
180
Serverless Framework ユーザーが CDK に引っ越しして感じたハードルについて言語化してみる
hassaku63
1
3.7k
[AWS Dev Day 2022 Japan] B-4 サーバーレスな社内業務システムを稼働させて1年経ったので、今日までの足跡を語ろうと思う/footprint-of-in-house-system-developed-fully-serverless-on-aws
hassaku63
1
1.7k
AWS X-Ray SDK for Python を使ってトレーサビリティを向上してみよう/start-aws-xray-and-xray-sdk-for-python
hassaku63
1
1.3k
思想から馴染ませるユニットテストの話/let-change-your-viewpoint-about-unit-test
hassaku63
0
200
Other Decks in Programming
See All in Programming
Zoneless Testing
rainerhahnekamp
0
120
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
命名をリントする
chiroruxx
1
420
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
260
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
5
710
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.7k
return文におけるstd::moveについて
onihusube
1
1.1k
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
290
useSyncExternalStoreを使いまくる
ssssota
6
1.1k
ドメインイベント増えすぎ問題
h0r15h0
2
350
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
6
1.4k
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Rails Girls Zürich Keynote
gr2m
94
13k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Building an army of robots
kneath
302
44k
Facilitating Awesome Meetings
lara
50
6.1k
Automating Front-end Workflow
addyosmani
1366
200k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Mobile First: as difficult as doing things right
swwweet
222
9k
Statistics for Hackers
jakevdp
796
220k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Designing for Performance
lara
604
68k
Transcript
ιʔείʔυΛշదʹҾ͖ܧ͍Ͱ͍ͨ͘Ίʹ Γ͍ͨ͜ͱ @hassaku July Tech Festa 2021 Winter (2021.01.24) #JTF2021w_f
- ίϯςφͱ VSCode Λͬͯ։ൃڥΛշదʹ͢Δ -
ࠓ͍ͨ͜͠ͱ • VSCode ͱίϯςφΛͬͯ։ൃڥΛշదʹ͍ͨ͠ • ϩʔΧϧͰಈ͔ͤΔ։ൃڥΛखʹೖΕΔ • ͦͷଞɺVSCode ͰೖΕ͍ͯΔઃఆͷ
hassaku (twitter: @hassaku_63) Serverworks Co., Ltd. ࣾSE
Interested in: • AWS CDK • Serverless • Python •
TypeScript
࣮ફ AWS CDK - TypeScript Ͱ ΠϯϑϥΞϓϦʂ https://booth.pm/ja/items/1881928 2020.03 -
2020.04 ٕज़ॻయ Ԡԉࡇ (ٕज़ॻయ8)
Agenda 1. ॱௐʹҾ͖ܧ͛ͳ͔ͬͨࢥ͍ग़ 2. “ִ͞Εͨ” ։ൃڥ 3. Docker Componse 4.
VSCode Remote Container
ॱௐʹҾ͖ܧ͛ͳ͔ͬͨࢥ͍ग़ ※લϑϦɻϑΟΫγϣϯͰ͢
͋ΔͷʢՍۭʣ ࣾSE ࠓ͔ΒอकΑΖ͘͠Ͷ ػೳվमͱόάใࠂདྷͯΔ͔Β ͳΔͰΑΖ͘͠ͶɻͳΔͰ
Կ͔ΒΩϟονΞοϓ͢Δʁ 1. ۓٸੑ·ͨॏཁͷߴ͍ Issue ͷ֬ೝ 2. ΞϓϦέʔγϣϯͷѲ 1. υΩϡϝϯςʔγϣϯͷॴࡏ 2.
ߏɺιʔεͷཧղ 3. σϓϩΠํ๏ͷ֬ೝ 4. ࢹܥͷΈͷ༗ແ 3. ݕূڥͷௐୡ
ΞϓϦέʔγϣϯͷѲ ԿΛѲ͢Δ͔ʁ • શମߏਤ • ґଘؔʢ֎෦αʔϏεʗύοέʔδʣ • ΞϓϦʗϞδϡʔϧߏ • ओཁͳϢʔεέʔε
ΞϓϦέʔγϣϯͷѲ Ͳ͏ͬͯѲ͢Δ͔ʁ • υΩϡϝϯςʔγϣϯͷॴࡏΛ֬ೝ • ιʔεͷ֬ೝ • ϑϨʔϜϫʔΫͷґଘؔ • σΟϨΫτϦߏ
• ݕূڥΛ༻ҙͯ͠ಈ͔ͯ͠ΈΔ
ΞϓϦέʔγϣϯͷѲ Ͳ͏ͬͯѲ͢Δ͔ʁ • υΩϡϝϯςʔγϣϯͷॴࡏΛ֬ೝ • ιʔεͷ֬ೝ • ϑϨʔϜϫʔΫͷґଘؔ • σΟϨΫτϦߏ
• ݕূڥΛ༻ҙͯ͠ಈ͔ͯ͠ΈΔ
ʮಈ͔ͯ͠ΈΔʯ͜ͱͷ͠͞ • ͜Ε͕Ͱ͖Δͱ৭ʑḿΔɻ͘͢͝ḿΔ • ಈ࡞ͷΠϝʔδΛ͔ͭΈ͍͢ • ڍಈͷ࠶ݱݕূΛ͘͢͠ͳΔ • ֎෦Өڹ͕ѲͰ͖ͳ͍͏ͪᷖᮣʹಈ͔ͤͳ͍ •
ຊ൪ڥͷ֎෦αʔϏεΛݺͼग़ͯ͠͠·͏͔ʁ • σʔλετΞͷ • ͋Δఔͷσʔλ͕ͳ͍ͱ࣮ࡍͷڍಈʹ͍ۙಈ࡞͕ݟ͑ͳ͍ • ݕূதʹॻ͖͑ͨσʔλͷ෭࡞༻Ͱ࠶ݱੑ͕औΕͳ͘ͳΔ • ্هΛΫϦΞͯ͠ɺʮͪΌΜͱʯಈ͔͢·Ͱʹϋʔυϧ͕͋Δ • ʁʁʁʮಈͣ͘ͳͷʹɺͳΜ͔ݟΒ͵Τϥʔ͕ग़ͯࢭ·ͬͯ͠·͏ΜͰ͚͢Ͳɾɾɾʯ • ϩʔΧϧPCʹطʹೖ͍ͬͯΔґଘؔͷɻωΠςΟϒϥΠϒϥϦͳͲ • ్தͰݕূతͰΠϯετʔϧ͍ͯͨ͠ʢຊདྷෆཁͳʣґଘؔͷ͍ͤͰඍົʹڥࠩҟ͕͋ͬͨ
• ͜Ε͕Ͱ͖Δͱ৭ʑḿΔɻ͘͢͝ḿΔ • ಈ࡞ͷΠϝʔδΛ͔ͭΈ͍͢ • ڍಈͷ࠶ݱݕূΛ͘͢͠ͳΔ • ֎෦Өڹ͕ѲͰ͖ͳ͍͏ͪᷖᮣʹಈ͔ͤͳ͍ • ຊ൪ڥͷ֎෦αʔϏεΛݺͼग़ͯ͠͠·͏͔ʁ
• σʔλετΞͷ • ͋Δఔͷσʔλ͕ͳ͍ͱ࣮ࡍͷڍಈʹ͍ۙಈ࡞͕ݟ͑ͳ͍ • ݕূதʹॻ͖͑ͨσʔλͷ෭࡞༻Ͱ࠶ݱੑ͕औΕͳ͘ͳΔ • ্هΛΫϦΞͯ͠ɺʮͪΌΜͱʯಈ͔͢·Ͱʹϋʔυϧ͕͋Δ • ʁʁʁʮಈͣ͘ͳͷʹɺͳΜ͔ݟΒ͵Τϥʔ͕ग़ͯࢭ·ͬͯ͠·͏ΜͰ͚͢Ͳɾɾɾʯ • ϩʔΧϧPCʹطʹೖ͍ͬͯΔґଘؔͷɻωΠςΟϒϥΠϒϥϦͳͲ • ్தͰݕূతͰΠϯετʔϧ͍ͯͨ͠ʢຊདྷෆཁͳʣґଘؔͷ͍ͤͰඍົʹڥࠩҟ͕͋ͬͨ ʮಈ͔ͯ͠ΈΔʯ͜ͱͷ͠͞ ͜ͷΜͷਏΈΛίϯςφϕʔεͷ։ൃڥ ʢͱ VSCode Ͱʣܰݮ͍ͨ͠
“ִ͞Εͨ” ։ൃڥ
ؾ҆͘৮ΕΔڥ͕΄͍͠ • ֎෦Өڹ͕ͳ͍͜ͱΛ֬৴Ͱ͖Δ͜ͱ • ΞϓϦ͔Βͷ Outbound ੍͕ݶʗېࢭ͞Ε͍ͯΔ • DBͷσʔλৗʹҰఆͷεφοϓγϣοτΛอ͍ͬͯͯ΄͍͠ •
ݕূͷաఔͰมߋͨ͠σʔλϦηοτ͍ͨ͠
։ൃڥͱͯ͠ͷίϯςφ (docker) • ڥͷ࠶ݱੑ • ։ൃڥʗಈ࡞ڥ Dockerfile ʹهड़ͯ͠Ϗϧυ • Կ͍ࣺͯͰ͖Δ
• ϩʔΧϧPCͷڥࠩҟΛഉআ • DockreHub ͷެࣜΠϝʔδ͕ॆ࣮ • ༗໊Ͳ͜Ζ͍͍ͩͨ͋Δ • DBܥͷΠϝʔδ dump ͔ΒॳظσʔλΛऔΓࠐΉํ๏αϙʔτ • docker-compose • AP-DB ͷෳίϯϙʔωϯτͷߏͱΕΔ • N/W पΓͷઃఆ compose ͷઃఆϑΝΠϧͰهड़
docker-compose
ExampleʢDjango + PostgreSQLʣ $POUBJOFS "QQ $POUBJOFS %# Host machine Docker
#SJHEF *' /FUXPSL *' Internet access
ExampleʢDjango + PostgreSQLʣ $POUBJOFS "QQ $POUBJOFS %# Host machine Docker
#SJHEF *' /FUXPSL *' Internet access
ExampleʢDjango + PostgreSQLʣ $POUBJOFS "QQ $POUBJOFS %# Host machine Docker
#SJHEF *' /FUXPSL *' Internet access
Example σΟϨΫτϦߏ • config … ϓϩδΣΫτ • polls … Django
App • Dockerfile … ΞϓϦέʔγϣϯίϯςφ • docker-compose … ݕূڥ • requirements*.txt … ґଘؔ # project # djnago app dir
Example docker-compose.yml • services • db … PostgreSQL • app
… Django DevServer • networks • ϒϦοδ & ֎ͷ௨৴Λېࢭ
Example docker-compose.yml • services • db … PostgreSQL • app
… Django DevServer • networks • ϒϦοδ & ֎ͷ௨৴Λېࢭ ্ཱͪ͛Δ ίϯςφͷఆٛ
Example docker-compose.yml • services • db … PostgreSQL • app
… Django DevServer • networks • ϒϦοδ & ֎ͷ௨৴Λېࢭ ίϯςφͷ N/W
Example - docker-compose docker-compose.yml networks
Example - docker-compose docker-compose.yml services.db
Example - docker-compose docker-compose.yml services.app command: python3 manage.py \ runserver
\ —settings config.settings_local
Example - App settings_local.py
Example - App settings_local.py • docker-compose.yml ͷઃఆ༰ͱ ಉ͡ͷΛهड़ • DBͷϗετ໊
yml Ͱఆٛͨ͠ αʔϏε໊ (=db) ͰղܾՄೳ
Example Django settings settings_local.py • docker-compose.yml ͷઃఆ༰ͱ ಉ͡ͷΛهड़ • DBͷϗετ໊
yml Ͱఆٛͨ͠ αʔϏε໊ (=db) ͰղܾՄೳ
Example - Build & Run > docker-compose build > docker-compose
up -d > docker-compose ps
Tips(1) - DB migration docker-compose exec ίϚϯυͰ migrate ͢Δ >
docker-compose exec <service> <command> manage.py migration
Tips(1) - DB migration docker-compose exec ίϚϯυͰ migrate ͢Δ >
docker-compose exec <service> <command> https://matsuand.github.io/docs.docker.jp.onthefly/compose/reference/exec/ manage.py dbshell
Tips(2) - ॳظσʔλೖ ެࣜΠϝʔδ͕ೖํ๏Λఏڙ͍ͯ͠Δ Postgres Ͱɺ /docker-entrypoint-initdb.d/ Լʹ *.sql ·ͨ
*.sql.gz ܗࣜͷμϯϓΛஔ͓͚ͯ͠OK https://hub.docker.com/_/postgres # Initialization scripts
Tips(2) - ॳظσʔλೖ (sample) σΟϨΫτϦߏ
Tips(2) - ॳظσʔλೖ (sample) docker-compose.yml ʢൈਮʣ postgres/Dockerfile
VSCode - Remote Container
Remote Container https://code.visualstudio.com/docs/remote/containers • VSCode ͷ֦ுػೳ • VSCode ্Ͱίϯςφͷ։ൃڥΛಈ͔ͤΔ
ͳʹ͕خ͍͠ʁ • ·ͬ͞Βͳ VM ʹઐ༻ͷ։ൃڥΛ࡞ͬͯ։ൃͰ͖ΔΠϝʔδ • docker-compose ୯ମͷ߹ΞϓϦͷ࣮ߦڥͷΈίϯςφԽ͢Δ • VSCode
্ͷ࣮ߦίϯςΩετίϯςφͷதʹͳΔ • ΤσΟλɺλʔϛφϧͳͲ • VSCode ͷଞͷػೳ͕ซ༻Ͱ͖Δʢ֦ுػೳؚΉʣ • ίϯςφ্ͷ։ൃڥͰσόοΨ͕͑ΔΑ͏ʹͳΔ • Linter Git पลͷ֦ுػೳͳͲ
Remote Container ίϚϯυύϨοτ (Ctrl+P) Λ։͍ͯ “Add Development Container …” Λબ
ϕʔεʹ͢ΔڥΛબ (Python3 & PostgreSQL)
Remote Container ίϯςφڥΛϏϧυ … Rebuild Container ίϯςφڥͰ VSCode Λ։͖͢ …Open
Workspace in Container
Remote Container Remote Container ؔͷઃఆϑΝΠϧ͕ੜ͞ΕΔ # VSCode Remote Container ͷઃఆϑΝΠϧ
↓ ”Dev Container”
↑ ίϯςφͷ /workspace Ͱλʔϛφϧ͕ىಈ
Remote Container Remote Container ؔͷઃఆϑΝΠϧ͕ੜ͞ΕΔ # VSCode Remote Container ͷઃఆϑΝΠϧ
ੜ͞Ε֤ͨϑΝΠϧͷղઆ ʢVSCode ʹΓସ͑ʣ
༨ஊ όΠϒϧ͕طʹ͋ͬͨ Atsushi Morimoto (@74th) ஶ https://74th.booth.pm/items/2425642
͓ΘΓʹ
·ͱΊ • docker-compose Ͱؾָʹ࡞ΕΔʢյͤΔʣ։ൃڥΛ खʹೖΕΑ͏ • VSCode ͍͍ͧ • ࢿྉɺαϯϓϧίʔυޙެ։༧ఆʢtwitterʣ
• ʢυΩϡϝϯτॻ͜͏ʣ