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
4
190
AWS re:Invent 2023 ML/AI x SaaS セッション振り返り/saas-eng-meetup-6_hassaku63
hassaku63
0
160
202310_社内LT/20231012_lighting_talk
hassaku63
0
48
CDK Day 2023 - Configure cross-account deployment using CDK
hassaku63
0
1.1k
CDK 座談会企画 2023-07 - CDK のメリットを再発掘してみよう
hassaku63
0
170
Serverless Framework ユーザーが CDK に引っ越しして感じたハードルについて言語化してみる
hassaku63
1
3.6k
[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
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
EventSourcingの理想と現実
wenas
6
2.3k
ヤプリ新卒SREの オンボーディング
masaki12
0
130
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
670
Amazon Qを使ってIaCを触ろう!
maruto
0
400
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
Arm移行タイムアタック
qnighy
0
320
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
32
1.5k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Code Review Best Practice
trishagee
64
17k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Producing Creativity
orderedlist
PRO
341
39k
For a Future-Friendly Web
brad_frost
175
9.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
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ʣ
• ʢυΩϡϝϯτॻ͜͏ʣ