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
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.6k
fs2-io を試してたらバグを見つけて直した話
chencmd
0
220
Refactor your code - refactor yourself
xosofox
1
260
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
return文におけるstd::moveについて
onihusube
1
940
MCP with Cloudflare Workers
yusukebe
2
220
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
120
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
Zoneless Testing
rainerhahnekamp
0
120
Criando Commits Incríveis no Git
marcelgsantos
2
170
Featured
See All Featured
Building Your Own Lightsaber
phodgson
103
6.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Faster Mobile Websites
deanohume
305
30k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Typedesign – Prime Four
hannesfritz
40
2.4k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Facilitating Awesome Meetings
lara
50
6.1k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Navigating Team Friction
lara
183
15k
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ʣ
• ʢυΩϡϝϯτॻ͜͏ʣ