๐Ÿ’ปDEV-STUDY/Docker

Docker Compose : ๋‘ ๊ฐœ ์ด์ƒ์˜ ๋„์ปค ์ด๋ฏธ์ง€ ๋นŒ๋“œ / ์ปจํ…Œ์ด๋„ˆ ๊ตฌ๋™Docker Compose๋ชฉ์ : Docker Compose๋ฅผ ํ†ตํ•œ Spring Boot + Database(MySQL) ๋™์‹œ ๊ตฌ๋™์ด๋ฒˆ ์ฑ•ํ„ฐ์—์„  Docker Compose๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•ž์„œ ์ง„ํ–‰ํ–ˆ๋˜ Spring Boot ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ MySQL ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๋™์‹œ์— ๊ตฌ๋™ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ๊ทธ ๊ณผ์ •์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž. Docker Compose๋ฅผ ํ†ตํ•ด ์—ฌ๋Ÿฌ ๊ฐœ์˜ Docker ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์†์‰ฝ๊ฒŒ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค. DockerFile: ํ•˜๋‚˜์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(์ด๋ฏธ์ง€)์„ ์ •์˜ํ•˜๊ณ  ๋นŒ๋“œํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.Docker Compose: ๋‘˜ ์ด์ƒ์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(์ด๋ฏธ์ง€)์„ ์ •์˜ํ•˜๊ณ  ํ•จ๊ป˜ ์‹คํ–‰ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. ๊ฐ ์ปจํ…Œ์ด๋„ˆ ๊ฐ„์˜ ๋„คํŠธ์›Œํฌ ์„ค์ • ๋ฐ ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •์„ ์‰ฝ..
Docker๋ฅผ ํ†ตํ•œ Database ๊ตฌ๋™Database: ์‚ฌ์šฉํ•˜๋ ค๋Š” DB์˜ Base Docker Image ๊ธฐ๋ฐ˜์— ์ถ”๊ฐ€ ์„ค์ •๋ชฉ์ : Docker๋ฅผ ํ†ตํ•œ Database(MySql) ๊ตฌ๋™ ← docker ๋ช…๋ น์–ด ์‚ฌ์šฉ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ตฌ๋™์€ Dockerfile ํ†ตํ•œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ ์—†์ด, ๋ฒ ์ด์Šค ์ด๋ฏธ์ง€๋กœ ๋ฐ”๋กœ ๊ตฌ๋™ํ•œ๋‹ค.1. MySQL ๋„์ปค ๊ตฌ๋™์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋ฐ”๋กœ ๊ตฌ๋™์ด ๊ฐ€๋Šฅํ•˜๋‹ค์ฃผ์˜: ๋„์ปค ๋‚ด ํฌํŠธ๋Š” 3306์ด์ง€๋งŒ, ๋กœ์ปฌ ๋…ธ์ถœ ํฌํŠธ๋Š” 33066docker run --name mysql-container \-e MYSQL_ROOT_PASSWORD=root \-e MYSQL_USER=asac \-e MYSQL_PASSWORD=1234 \-e MYSQL_DATABASE=example \-p 33066:3306 -d my..
๊ฐœ๋ฐœํ™˜๊ฒฝ๊ณผ ๋ฐฐํฌํ™˜๊ฒฝ์˜ ๋ถ„๋ฆฌ, ์ผ๊ด€๋œ ์‹คํ–‰ ํ™˜๊ฒฝWhy Use to Docker?๋„์ปค๋ผ์ด์ฆˆ๋ฅผ ์ ์šฉํ•˜๊ธฐ์— ์•ž์„œ, Docker๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ทผ๋ณธ์ ์ธ ์ด์œ ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.๊ฒฉ๋ฆฌ(Isolation): ๋กœ์ปฌ(์ธ์Šคํ„ด์Šค)์˜ ํ™˜๊ฒฝ๊ณผ ๋ถ„๋ฆฌ๋œ ๋„์ปค ํ™˜๊ฒฝ์œผ๋กœ ๋กœ์ปฌ ํ™˜๊ฒฝ์˜ ์˜ค์—ผ์ด๋‚˜ ์ถฉ๋Œ์„ ๋ฐฉ์ง€ํ•œ๋‹ค.์ผ๊ด€์„ฑ(Consistency): ๋‹ค์–‘ํ•œ ๋กœ์ปฌ(์ธ์Šคํ„ด์Šค)์—์„œ๋„ ๋„์ปค๋ฅผ ํ†ตํ•ด ์ผ๊ด€๋œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ตฌ๋™ํ•  ์ˆ˜ ์žˆ๋‹ค.Docker๊ฐ€ ์—†์„ ๋•Œ:๋กœ์ปฌ(์ธ์Šคํ„ด์Šค) ํ™˜๊ฒฝ๊ณผ App ๊ตฌ๋™์„ ์œ„ํ•œ ํ™˜๊ฒฝ์ด ์ถฉ๋Œํ•˜๊ณ  ์ด๋ฆฌ์ €๋ฆฌ ์„ž์ธ๋‹ค.๋ฌธ์ œ์ : ๊ฐ ๊ฐœ๋ฐœ์ž์˜ ๋กœ์ปฌํ™˜๊ฒฝ์ด ์„œ๋กœ ๋‹ฌ๋ผ, ์ผ๊ด€๋œ ํ™˜๊ฒฝ ๊ตฌ์„ฑ์ด ์–ด๋ ต๋‹ค.Aaron: Window OS์—์„œ MySQL 5.7, JVM 17, 16, 12Baron: Linux OS์—์„œ MySQL 8, JVM 17, 8Caron: Ma..
์‹ค์Šต #3์•ž์„  ํฌ์ŠคํŒ…์—์„œ ์–ธ๊ธ‰ํ–ˆ๋“ฏ, ๋งค๋ฒˆ ๋ฐฐํฌ ์‹œ, GitHub Actions๊ฐ€ Docker Hub์— ์ด๋ฏธ์ง€๋ฅผ ํ‘ธ์‹œํ•˜๊ณ , ๊ฐœ๋ฐœ์ž๊ฐ€ EC2์— ์ง์ ‘ ์ ‘์†ํ•ด ์ˆ˜๋™์œผ๋กœ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์™€ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์€ ๋ฒˆ๊ฑฐ๋กญ๊ณ  ๋น„ํšจ์œจ์ ์ด๋‹ค. ๋”ฐ๋ผ์„œ, Github Actions๊ฐ€ ์ด๋ฏธ์ง€๋ฅผ Docker Hub์— ํ‘ธ์‹œํ•œ ํ›„ ์ž๋™์œผ๋กœ EC2์— ์ ‘์†ํ•ด ์ด๋ฏธ์ง€๋ฅผ Pullํ•˜๊ณ  ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•˜๋„๋ก ์„ค์ •ํ•˜๋ฉด ํ›จ์”ฌ ๋” ์ˆ˜์›”ํ•˜๊ณ  ํŽธ๋ฆฌํ•˜๊ฒŒ ์ž๋™ ๋ฐฐํฌ๋ฅผ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„  ์ž๋™์œผ๋กœ ์ด๋ฏธ์ง€๋ฅผ Pull, ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•˜๋„๋ก ์„ค์ •ํ•˜๋Š” ์ž‘์—… ๊ณผ์ •์„ ํฌ์ŠคํŒ…ํ•  ์˜ˆ์ •์ด๋‹ค.์ด ์ž๋™ํ™” ๋ฐฉ์‹์—์„œ๋Š” GitHub Actions๊ฐ€ EC2์— SSH๋กœ ์ ‘๊ทผํ•ด ๋‹ค์Œ ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.Docker Hub์—์„œ ์ตœ์‹  ์ด๋ฏธ์ง€ Pull: ์ƒˆ๋กœ์šด ์ด๋ฏธ์ง€๊ฐ€ ์ƒ์„ฑ๋˜..
์‹ค์Šต #21.  AWS EC2 ์ƒ์„ฑ์ฒซ๋ฒˆ์งธ๋กœ ํ˜„์žฌ CD๋ฅผ ํ†ตํ•ด Spring์„ ๊ตฌ๋™ํ•  AWS EC2๊ฐ€ ์•„์ง ์—†์œผ๋‹ˆ ์ธ์Šคํ„ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค.ํ‚คํŽ˜์–ด๋Š” ์—†์ด ์ง„ํ–‰.์ด์ „์— ๋งŒ๋“ค์—ˆ๋˜ VPC๋กœ ์ง„ํ–‰ํ•  ์˜ˆ์ • (https://1000sang-dev.tistory.com/64) ํผ๋ธ”๋ฆญ IP ์ž๋™ ํ™œ์„ฑํ™” ์„ค์ •๋ณด์•ˆ ๊ทธ๋ฃน์˜ ๊ฒฝ์šฐ ๊ธฐ์กด 22๋ฒˆ ํฌํŠธ ์™ธ์— "8080 ํฌํŠธ์˜ ๋ชจ๋“  IP" ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์„ ์ถ”๊ฐ€ํ•ด์ค˜์•ผํ•œ๋‹ค.์‚ฌ์šฉ์ž ์ง€์ • TCP ํฌํŠธ 8080 ์ž…๋ ฅ → ์œ„์น˜ ๋ฌด๊ด€(๋ชจ๋“  IP) ์ถ”๊ฐ€EC2 ์—ฐ๊ฒฐ ํ™•์ธ ์•„๋ž˜ ์ด๋ฏธ์ง€๋ฅผ ํ†ตํ•ด EC2 ์ธ์Šคํ„ด์Šค ์—ฐ๊ฒฐ์„ ํ†ตํ•ด ์ ‘์†์„ ์„ฑ๊ณตํ•œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ๐Ÿ‘ 2. ์ƒ์„ฑํ•œ AWS EC2 ๋‚ด Docker ์„ค์น˜๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ์ปจํ…Œ์ด๋„ˆ๋กœ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์€ Docker Daemon(Docker Engine)์ด๋‹ค.์ง€๊ธˆ..
์‹ค์Šต #1 1. CI ์‚ฌ์ „ ์ค€๋น„: ๋ฐฐํฌํ•˜๊ณ ์ž ํ•˜๋Š” Java ์ฝ”๋“œ ์ž‘์„ฑ ๋ฐ Github ์—…๋กœ๋“œโš ๏ธ ํ•„์ž๋Š” ์ด์ „์— ๊ณต๋ถ€ํ–ˆ๋˜ Spring ์‹ค์Šต ์ฝ”๋“œ๋ฅผ Github๋ฅผ ์ด์šฉํ•  ์˜ˆ์ •์ด๋‹ค. 1. ๋””ํดํŠธ ๋ธŒ๋žœ์น˜ ์ด๋ฆ„์„ main์œผ๋กœ ๋ฐ”๊พธ์–ด์ค€๋‹ค.ํ•„์ž๋Š” main ๋ธŒ๋žœ์น˜๋กœ ๋ฐฐํฌํ•  ๊ฒƒ์ž„.git branch -m main 2. ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ์ƒ์„ฑํ•œ ํ›„, ์›๊ฒฉ ์ €์žฅ์†Œ(Github Repository)์— Push. (sanghyun-e/ci-ci-tutorial) ์›๊ฒฉ ์ €์žฅ์†Œ๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ git remote add origin git@github.com:SangHyun-e/ci-cd-tutorial.git ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒฝ์šฐgit remote set-url origin git@github.com:SangHyun-e/ci-c..
Event, Runner, Job, Step, ActionCI / CD Tool: GitHub ActionsGitHub Actions vs Jenkins CI / CD ํˆด๋กœ ์œ ๋ช…ํ•œ ๊ฒƒ์€ GitHub Action๊ณผ Jenkins๊ฐ€ ์žˆ๋‹ค. Jenkins๋Š” ๋ณ„๋„์˜ Jenkins ์„œ๋ฒ„๋ฅผ ๋”ฐ๋กœ ๊ตฌ์ถ•ํ•ด์•ผ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฌด๋ฃŒ ํˆด์ธ GitHub Action์„ ์‚ฌ์šฉํ•  ์˜ˆ์ •์ด๋‹ค. Why Use to GitHub Actions?CI / CD ๊ฐ„์†Œํ™”: ๋ณ„๋„์˜ ์„œ๋ฒ„(Jenkins ๋“ฑ)๋ฅผ ๊ตฌ์ถ•ํ•  ํ•„์š” ์—†์ด GitHub์—์„œ ๋ฌด๋ฃŒ๋กœ ์ œ๊ณตํ•œ๋‹ค.์›ํ™œํ•œ ํ†ตํ•ฉ: GitHub ์ €์žฅ์†Œ์™€ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์—ฐ๋™๋˜์–ด ์ž๋™ํ™” ๋ฐ ๋ฐ˜๋ณต์ ์ธ ์ž‘์—… ์ˆ˜ํ–‰์— ์œ ๋ฆฌํ•จ.CI / CD ๊ฐœ๋…CI (Continuous Integration): ์ฝ”๋“œ๊ฐ€ ์ง€์†์ ์œผ๋กœ ํ†ตํ•ฉ๋˜์–ด ๋นŒ๋“œ ..
1000_sang
'๐Ÿ’ปDEV-STUDY/Docker' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก