Bibi's DevLog ๐Ÿค“๐ŸŽ

Heroku๋กœ ์Šคํ”„๋ง ์•ฑ ๋ฐฐํฌํ•˜๊ธฐ ๋ณธ๋ฌธ

๐Ÿ–ฅ BE ๋ฐฑ์—”๋“œ/Spring ์Šคํ”„๋ง

Heroku๋กœ ์Šคํ”„๋ง ์•ฑ ๋ฐฐํฌํ•˜๊ธฐ

๋น„๋น„ bibi 2021. 3. 15. 23:34

Heroku๋กœ ์Šคํ”„๋ง ์•ฑ ๋ฐฐํฌํ•˜๊ธฐ

๊ธฐ๋ณธ์ ์ธ ๋ฐฉ๋ฒ•, ๋กœ์น˜์˜ ๋…ธ์…˜, main์™ธ์˜ ๋ธŒ๋žœ์น˜๋กœ ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ๋ฒ•

master๊ฐ€ ์•„๋‹Œ forkํ•œ ๋ธŒ๋žœ์น˜๋ช…์œผ๋กœ ๋ฐฐํฌํ•ด์•ผ ํ–ˆ๋Š”๋ฐ ๋ช…๋ น์–ด๊ฐ€ ์กฐ๊ธˆ ๋‹ฌ๋ผ์„œ ์•ˆ ๋๋˜ ๊ฑฐ์˜€๋‹ค!!

๋„์›€ ์ฃผ์‹  ๊ทธ๋ฃน์› coco, sky ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค๐Ÿ™‡โ€โ™€๏ธ๐Ÿ™‡โ€โ™€๏ธ

  1. ๋จผ์ € Heroku ๊ณ„์ •์„ ๋งŒ๋“ค๊ณ  Heroku CLI๋ฅผ ๋‹ค์šด๋กœ๋“œ, ์„ค์น˜ํ•œ๋‹ค. (https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku)

  2. ํ„ฐ๋ฏธ๋„์—์„œ heroku login์„ ์ž…๋ ฅํ•˜๊ณ  ๋งŒ๋“  ํ—ค๋กœ์ฟ  ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธํ•œ๋‹ค.

  3. heroku keys๋ฅผ ์ž…๋ ฅํ•ด SSH ํ‚ค๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ , ์•„๋ฌด๊ฒƒ๋„ ์—†์œผ๋ฉด heroku keys:add๋กœ ํ‚ค๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

  4. ๋ฐฐํฌํ•  ์Šคํ”„๋ง ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์žˆ๋Š” ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•œ๋‹ค (cd ...)

  5. ํ•ด๋‹น ์•ฑ์— ๋Œ€ํ•œ ๊นƒ ์ €์žฅ์†Œ๋ฅผ ๋งŒ๋“ค๊ณ  ๋ชจ๋“  ์ฝ”๋“œ๋ฅผ add, commitํ•œ๋‹ค

  6. heroku create๋ฅผ ์ž…๋ ฅํ•ด Heroku ์•ฑ์„ ๋งŒ๋“ค๊ณ  ์›๊ฒฉ ์ €์žฅ์†Œ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

    ์ด๋ฆ„์€ ๋žœ๋ค์œผ๋กœ ์ •ํ•ด์ง. ๋งˆ์Œ์— ๋“ค์ง€ ์•Š์œผ๋ฉด heroku apps:rename์œผ๋กœ ์ด๋ฆ„์„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค.

    git remote -v๋กœ Heroku ์›๊ฒฉ ์ €์žฅ์†Œ๊ฐ€ ์ž˜ ๋งŒ๋“ค์–ด์กŒ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

  7. ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด git push heroku master ๋˜๋Š” git push heroku main์„ ์ž…๋ ฅํ•œ๋‹ค.

    โ— ๋งŒ์•ฝ ๋ฐฐํฌํ•  ๋ธŒ๋žœ์น˜ ์ด๋ฆ„์ด master, main์ด ์•„๋‹ˆ๋ผ๋ฉด,

    git push heroku ๋ธŒ๋žœ์น˜๋ช…:master ๋กœ ๋ฐฐํฌํ•œ๋‹ค.

    (Heroku๊ฐ€ push ๋ฐ ๋นŒ๋“œ๋ฅผ ๋‹ค ํ•ด ์ฃผ๋ฏ€๋กœ ์‹œ๊ฐ„์ด ์กฐ๊ธˆ ๊ฑธ๋ฆฐ๋‹ค)

  8. ๋ฐฐํฌ๊ฐ€ ์ž˜ ๋˜์—ˆ๋‹ค๋ฉด heroku open์„ ์ž…๋ ฅํ•ด ๋ธŒ๋ผ์šฐ์ €์—์„œ ๋‚ด ์Šคํ”„๋ง ์•ฑ์ด ์ž˜ ์‹คํ–‰๋˜๋Š”์ง€ ํ™•์ธํ•œ๋‹ค