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
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
CSC509 Lecture 13
javiergs
PRO
0
110
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
Contemporary Test Cases
maaretp
0
140
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Jakarta EE meets AI
ivargrimstad
0
590
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Featured
See All Featured
Scaling GitHub
holman
458
140k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Six Lessons from altMBA
skipperchong
27
3.5k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Practical Orchestrator
shlominoach
186
10k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Rails Girls Zürich Keynote
gr2m
94
13k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Being A Developer After 40
akosma
87
590k
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ʣ
• ʢυΩϡϝϯτॻ͜͏ʣ