๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐ•์˜ ์ •๋ฆฌ/CLASS101 ๋ฐฑ์—”๋“œ ์‹œ์Šคํ…œ ์‹ค๋ฌด

Chapter2 - CPU Bound ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ Dockerized ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ GCP ๋ฐฐํฌ

by ์ฃผ๋ฐœ2 2021. 2. 26.
๋ฐ˜์‘ํ˜•

 ์•ˆ๋…•ํ•˜์„ธ์š”~ ์ด์ „์— ์šด์˜ํ•˜๋˜ ๋ธ”๋กœ๊ทธ ๋ฐ GitHub, ๊ณต๋ถ€ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•˜๋Š” Study-GitHub ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค!

 ๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ

 GitHub

Study-GitHub

 ๐Ÿ”


โœ” CLASS101 ๋ฐฑ์—”๋“œ ์‹œ์Šคํ…œ ์‹ค๋ฌด - Chapter2 CPU Bound ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜

์•ˆ๋…•ํ•˜์„ธ์š”, ํด๋ž˜์Šค101 ๋ฐฑ์—”๋“œ ์‹œ์Šคํ…œ ์‹ค๋ฌด ๊ฐ•์˜๋ฅผ ๋“ฃ๊ณ , ๋ณต์Šต ์ฐจ์›์œผ๋กœ ์ •๋ฆฌํ•˜์—ฌ ๋‚จ๊ธฐ๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค!

ํ˜น์‹œ ๋ฌธ์ œ๊ฐ€ ๋œ๋‹ค๋ฉด ๊ธ€์„ ์‚ญ์ œํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค !!

 

class101.net/products/5fc4a3b4fc231b000d85661b

 

ํ˜„์ง ๋Œ€๊ธฐ์—… ๊ฐœ๋ฐœ์ž ํ‘ธ์™€ ํ•จ๊ป˜ํ•˜๋Š” ์ง„์งœ ๋ฐฑ์—”๋“œ ์‹œ์Šคํ…œ ์‹ค๋ฌด!

IT ๋Œ€๊ธฐ์—…๋“ค์˜ ๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ๊ณต๊ณ ๋ฅผ ๋ณธ ์  ์žˆ๋‚˜์š”? ๐Ÿ“์œ„ ๋ฐ‘์ค„ ์นœ ๋ถ€๋ถ„์„ ๋ฐฐ์šธ ์ˆ˜ ์žˆ๋„๋ก ์ปค๋ฆฌํ˜๋Ÿผ์„ ๊ตฌ์„ฑํ–ˆ์–ด์š”. ๊ฒ‰๋ณด๊ธฐ์—” ์–ด๋ ค์›Œ ๋ณด์ด์ง€๋งŒ, ๊ฒฐ๊ตญ ๋ฐฐ์šฐ๊ณ  ๋‚˜๋ฉด ๋‚˜๋„ ์ €๋Ÿฐ ๊ณณ์—์„œ ์ผํ•  ์ˆ˜ ์žˆ

class101.net


 

 

 

โœ” Dockerized ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ GPC์— ๋ฐฐํฌํ•˜๊ธฐ

 

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ๋„์ปค ํŒŒ์ผ์ด ์ด๋ฏธ์ง€๊ฐ€ ๋˜์—ˆ๋‹ค๊ฐ€ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๋˜๋Š” ๊ณผ์ •

Docker ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ GCP ๋ฐฐํฌ ๊ณผ์ •

• dockerfile์„ docker image๋กœ build

docker image๋ฅผ dockerHub์— push

dockerHub์— ์กด์žฌํ•˜๋Š” docker image๋ฅผ GCP๋กœ pull

• GCP์—์„œ docker image๋ฅผ run(container, ์ปจํ…Œ์ด๋„ˆ)

 

 

 

 

๐ŸŽ— ์Šคํ”„๋ง๋ถ€ํŠธ, Docker ๊ณต์‹ ๋ฌธ์„œ

spring.io/guides/gs/spring-boot-docker/

 

Spring Boot with Docker

this guide is designed to get you productive as quickly as possible and using the latest Spring project releases and techniques as recommended by the Spring team

spring.io

 

 

๐ŸŽ— dockerfile

์ธํ…”๋ฆฌ์ œ์ด์— Dockerfile ํŒŒ์ผ์„ ์ƒ์„ฑ ํ›„ ์œ„ ๋‚ด์šฉ์„ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.

 

 

 

 

๐ŸŽ— dockerHub

hub.docker.com/

 

Docker Hub

We and third parties use cookies or similar technologies ("Cookies") as described below to collect and process personal data, such as your IP address or browser information. You can learn more about how this site uses Cookies by reading our privacy policy

hub.docker.com

Docker Hub์—์„œ ํšŒ์›๊ฐ€์ž…์„ ํ•œ ํ›„ Repositories๋กœ ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค.

 

 

 

 

๊ทธ ํ›„ Create Repository๋กœ ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค.

 

 

 

์œ„์™€ ๊ฐ™์ด Repository์˜ ์ด๋ฆ„์„ ์ž‘์„ฑํ•˜๊ณ , Public์œผ๋กœ ํ•œ ๋’ค ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

 

 

 

 

๐ŸŽ— build(dockerfile -> docker image)

๊ทธ ํ›„ ์ธํ…”๋ฆฌ์ œ์ด์˜ Terminal์—์„œ ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

docker build -t docker๊ณ„์ •/repo ์ด๋ฆ„ .

 

 

 

 

๋กœ์ปฌ์—์„œ docker image ๋ฅผ ๋จผ์ € ๋„์–ด๋ด…๋‹ˆ๋‹ค.

 

 

 

 

๊ธฐ์กด์—๋Š” jar ํŒŒ์ผ์„ ์ง์ ‘ ์‹คํ–‰ํ–ˆ์œผ๋‚˜, ํ˜„์žฌ๋Š” docker image ๋‚ด๋ถ€์— ์žˆ๋Š” jar ํŒŒ์ผ์„ ์‹คํ–‰ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์œ„ ๊ณผ์ •์„ ์ง„ํ–‰ ํ›„ localhost:hash/123 ์œผ๋กœ ํ…Œ์ŠคํŠธ๋ฅผ ํ•œ ๋’ค ์—ฐ๊ฒฐ์ด ๋˜๋ฉด ์„ฑ๊ณต์ ์œผ๋กœ ์‹คํ–‰์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜

 

 

 

๐ŸŽ— push(Local -> dockerHub)

์ธํ…”๋ฆฌ์ œ์ด์—์„œ ์‹คํ–‰์„ ์ข…๋ฃŒ(Ctrl + C) ํ•˜๊ณ , docker image๋ฅผ Docker Hub๋กœ  push ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Docker Hub์— ์กด์žฌํ•˜๋Š” commands ์—์„œ push๋ฅผ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

 

tagname์€ ์ง€์ •ํ•˜์ง€ ์•Š์•˜์œผ๋ฏ€๋กœ, ์ง€์šฐ๊ณ  ์œ„ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

(ํ˜น์‹œ ์ง„ํ–‰ ๋„์ค‘ denied: ์ ‘๊ทผ ๊ฑฐ๋ถ€๊ฐ€ ๋‚˜์˜ค๋ฉด, docker login ์„ ํ†ตํ•ด Docker Hub์— ๋กœ๊ทธ์ธ์„ ํ•ด์ค๋‹ˆ๋‹ค.)

 

 

 

 

er push juhyun419/spring-boot-cpu-bound:tagname

Docker Hub์—์„œ ์ƒˆ๋กœ๊ณ ์นจ์„ ํ•˜๋ฉด ์œ„์™€ ๊ฐ™์ด ์ƒˆ๋กœ์šด TAG๊ฐ€ ์ƒ๊ธด๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด์ œ GCP์—์„œ ํ•ด๋‹น docker image๋ฅผ ๋ฐ›์•„์˜ค๋ฉด ๋˜๋Š”๋ฐ์š”, ์ƒˆ๋กœ์šด GCP ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•œ ํ›„ SSH๋กœ ์ ‘์†์„ ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

๐ŸŽ— GCP

SSH์—์„œ docker๋ฅผ ๋จผ์ € ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

$ sudo yum install docker

 

๊ทธ ํ›„ docker๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

$ sudo sytemctl start docker

 

 

 

๐ŸŽ— GCP pull

Docker Hub์— pushํ–ˆ๋˜ docker image๋ฅผ pull ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

๐ŸŽ— GCP run

docker image๋ฅผ runํ•ฉ๋‹ˆ๋‹ค.

 

 

์Šคํ”„๋ง ๋ถ€ํŠธ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰์ด ๋˜๋Š”๋ฐ์š”, ๋งˆ์ฐฌ๊ฐ€์ง€ URL์— ์ ‘์†ํ•ด์„œ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€