Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

Latest commit

ย 

History

History
54 lines (35 loc) ยท 3.79 KB

deployChapter.md

File metadata and controls

54 lines (35 loc) ยท 3.79 KB

7. ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฐฐํฌํ•˜๊ธฐ

๋งˆ์ง€๋ง‰ ์žฅ์—์„œ๋Š” ๋ฆฌ์•กํŠธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์— ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ฌด๋ฃŒ ํ˜ธ์ŠคํŒ… ์„œ๋น„์Šค์ธ ํ—ค๋กœ์ฟ (Heroku)์— ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ฐฐํฌ ๊ณผ์ •์—์„œ create-react-app์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ด…์‹œ๋‹ค.

7.1 Eject

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด 'Eject'์— ๋Œ€ํ•ด ์•Œ ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค. create-react-app์€ ํ™•์žฅ์„ ์œ ์ง€ํ•˜๋ฉด์„œ ๋ฒค๋” ์ข…์†์„ ๋ฐฉ์ง€ํ•˜๋Š” ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. (๋ฒค๋” ์ข…์†(vendor lock-in)์ด๋ž€ ์–ด๋–ค ํšŒ์‚ฌ์˜ ์ œํ’ˆ์— ๋Œ€ํ•ด ์†Œ๋น„์ž๊ฐ€ ์ข…์†๋˜๋Š” ์ƒํ™ฉ์— ์ด๋ฅด๊ฒŒ ๋˜๋Š” ํ˜„์ƒ์„ ๋งํ•ฉ๋‹ˆ๋‹ค. ์†Œ๋น„์ž๊ฐ€ ๋‹ค๋ฅธ ํšŒ์‚ฌ์˜ ์ƒํ’ˆ์œผ๋กœ ์˜ฎ๊ฒจ๊ฐ€๊ณ  ์‹ถ์–ด๋„ ๊ฐˆ ์ˆ˜ ์—†๋„๋ก ๋งŒ๋“ค์–ด ๋†“์€ ์ƒํ™ฉ์— ์ด๋ฅด๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. โ€œ๋น„ํ˜ธํ™˜์„ฑโ€์ด ๋Œ€ํ‘œ์ ์ธ ์˜ˆ ์ž…๋‹ˆ๋‹ค.) ๋ฒค๋” ์ข…์†์€ ํŠน์ • ๊ธฐ์ˆ ์„ ๊ตฌ๋งคํ•˜์—ฌ ๋„์ž…ํ•  ๋•Œ ๋ฌธ์ œ์‹œ ๋ฉ๋‹ˆ๋‹ค. ํŠน์ • ๊ธฐ์ˆ ์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด ํƒˆํ”ผํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์€ ์—†์Šต๋‹ˆ๋‹ค. ๋‹คํ–‰์ด๋„ create-react-app์€ "eject(๊บผ๋‚ด๊ธฐ)"๋กœ ๋ฒค๋” ์ข…์†์„ ํƒˆํ”ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

package.json ํŒŒ์ผ์— start, test, build ์Šคํฌ๋ฆฝํŠธ ๋ช…๋ น์–ด๊ฐ€ ๋ณด์ผ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋งจ ๋งˆ์ง€๋ง‰์— eject๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. eject ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•ด๋ณผ ์ˆ˜๋Š” ์žˆ๊ฒ ์ง€๋งŒ, ๋‹ค์‹œ ์ „ ์ƒํƒœ๋กœ ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์€ ์—†์Šต๋‹ˆ๋‹ค. ๋‹จ๋ฐฉํ–ฅ ์กฐ์ž‘์ด๊ธฐ ๋•Œ๋ฌธ์— ์ ˆ๋Œ€๋กœ ์ „ ์ƒํƒœ๋กœ ๊ฐˆ ์ˆ˜ ์—†๋‹ค๋Š” ๊ฒƒ์„ ๋ช…์‹ฌํ•˜๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค! ์ด์ œ ๋ฆฌ์•กํŠธ ์ž…๋ฌธ์ž์ผ์ˆ˜๋ก, create-react-app ์ œ๊ณต๋˜๋Š” ๊ธฐ๋ณธ ๋„๊ตฌ๋ฅผ ์ถฉ์‹คํžˆ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

npm run eject ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด package.json ์— ์ •์˜๋œ ๋ชจ๋“  ์„ค์ •๊ณผ ์˜์กด์„ฑ์„ ๋ณต์‚ฌํ•ด ์ƒˆ ํด๋”์ธ config/ ์ƒ์„ฑํ•˜์—ฌ ์ด ํด๋”๋กœ ๋ชจ๋‘ ์ด๋™์‹œํ‚ต๋‹ˆ๋‹ค. ๋ฐ”๋ฒจ(Babel)๊ณผ ์›นํŒฉ(Webpack)์„ ์‚ฌ์šฉํ•ด ๋งŒ๋“  ์ปค์Šคํ…€ ์„ค์ •์œผ๋กœ ์ „์ฒด ํ”„๋กœ์ ํŠธ๋ฅผ ์ปจ๋ฒ„ํŒ…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐ”๋ฒจ๊ณผ ์›นํŒฉ ๋“ฑ ๋ชจ๋“  ํˆด์„ ๋Šฅ์ˆ™ํ•˜๊ฒŒ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ์„ ๋•Œ ํ•ด๋ณด๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

create-react-app ๋Š” ์†Œ๊ทœ๋ชจ ํ”„๋กœ์ ํŠธ์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ง€๊ธˆ ๋‹จ๊ณ„์—์„œ "eject"๋ฅผ ์‚ฌ์šฉํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

์ฝ์–ด๋ณด๊ธฐ

7.2 Heroku ๋ฐฐํฌ

์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“  ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ—ค๋กœ์ฟ (Heroku)์— ๋ฐฐํฌํ•ด๋ด…์‹œ๋‹ค. ํ—ค๋กœ์ฟ ๋Š” create-react-app์˜ ์ œ๋กœ ๊ตฌ์„ฑ ์„ค์น˜ ์ฒ ํ•™์„ ๋”ฐ๋ฅด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋ช‡ ๋ถ„๋งŒ์— create-react-app ์•ฑ์„ ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฐฐํฌ ์ „ ๊ผญ ํ•ด์•ผํ•  ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ™ˆ๋ธŒ๋กœ์šฐ(Homebrew)๋กœ ํ—ค๋กœ์ฟ  CLI๋ฅผ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

{title="Command Line",lang="text"}

brew update
brew install heroku-toolbelt

์ด์ œ ๊นƒ๊ณผ ํ—ค๋กœ์ฟ  CLI๋กœ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•ฉ๋‹ˆ๋‹ค.

{title="Command Line",lang="text"}

git init
heroku create -b https://github.com/mars/create-react-app-buildpack.git
git add .
git commit -m "react-create-app on Heroku"
git push heroku master
heroku open

์ด ๊ฒƒ์œผ๋กœ ๋ฐฐํฌ๋ฅผ ๋งˆ์น˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ง€๊ธˆ๊นŒ์ง€ ๊ฐœ๋ฐœํ•œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์™„๋ฒฝํ•˜๊ฒŒ ์ž‘๋™๋˜๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค. ์•ž์œผ๋กœ ์•„๋ž˜ ์ฐธ๊ณ ์ž๋ฃŒ๋ฅผ ๋ณด๊ณ  ๋” ๊นŠ์ด ํ•™์Šตํ•ด๋ณด๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

์ฝ์–ด๋ณด๊ธฐ