๐Ÿ”ฅ Firebase ํ˜ธ์ŠคํŒ…์œผ๋กœ ์›น์‚ฌ์ดํŠธ ๋ฐฐํฌ

6802 ๋‹จ์–ด githubfirebasecicdhosting
๐Ÿ‡ซ๐Ÿ‡ท French version

๋ฐฐํฌ๋ฅผ ์œ„ํ•œ ๋…น์ƒ‰ ํ‘œ์‹œ๋“ฑ



๐ŸŒ ์‡ผ์ผ€์ด์Šค ์‚ฌ์ดํŠธ, ํฌํŠธํด๋ฆฌ์˜ค ๋˜๋Š” ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๊ด€๊ณ„์—†์ด ๊ฐœ๋ฐœ์ž์˜ ๋งˆ์ง€๋ง‰ ๋‹จ๊ณ„๋Š” ๋ชจ๋“  ์‚ฌ๋žŒ์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ธํ„ฐ๋„ท ์ฃผ์†Œ์—์„œ ํ”„๋กœ๋•์…˜์— ์ ์šฉํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๐Ÿ”ฅ ์˜ค๋Š˜์€ ํ˜ธ์ŠคํŒ… ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์ดํŠธ๋ฅผ ๋น ๋ฅด๊ณ  ๋ฌด๋ฃŒ๋กœ ๋ฐฐํฌํ•  ์ˆ˜ ์žˆ๋Š” Firebase๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.



๐Ÿ’ธ Firebase๋Š” pay-as-you-go ๋„๊ตฌ์ด๋ฏ€๋กœ ์‚ฌ์šฉํ•œ ๋งŒํผ ์†Œ๋น„ํ•ฉ๋‹ˆ๋‹ค. ํ˜ธ์ŠคํŒ…์˜ ๊ฒฝ์šฐ ๋ฌด๋ฃŒ์ œ๊ณต(์‹ ์šฉ์นด๋“œ ์ž…๋ ฅ ๋ถˆ๊ฐ€)์œผ๋กœ 10GB์˜ ์ €์žฅ๊ณต๊ฐ„๊ณผ ํ•˜๋ฃจ 360MB์˜ ์ „์†ก์„ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๋„๋ฉ”์ธ ์ด๋ฆ„๊ณผ SSL์ด ํฌํ•จ๋œ ๋งํฌ๋„ ์ œ์•ˆ์— ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌ๋‚˜ ๋„๋ฉ”์ธ ์ด๋ฆ„์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๋จผ์ € ๋„๋ฉ”์ธ ์ด๋ฆ„์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค!

๋ฐฐํฌ๋ฅผ ์‹œ์ž‘ํ•˜๋ ค๋ฉด npm ๋ฐ firebase-tools CLI๊ฐ€ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

npm install -g firebase-tools


ํ”„๋กœ์ ํŠธ ๊ตฌ์„ฑ์— ๋”ฐ๋ผ ์„ค์น˜ ์ ˆ์ฐจ๊ฐ€ ๋‹ค๋ฆ…๋‹ˆ๋‹ค. ๋” ์™„๋ฒฝํ•˜๊ฒŒ ํ•˜๋ ค๋ฉด ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋”ฐ๋ฅด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

๐Ÿ’ช CLI๊ฐ€ ์„ค์น˜๋˜๋ฉด firebase login๋กœ Firebase ๊ณ„์ •์— ์—ฐ๊ฒฐํ•œ ๋‹ค์Œ ํ”„๋กœ์ ํŠธ ํด๋”์—์„œ firebase init๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ์•„๋ฆ„๋‹ค์šด Firebase CLI๋ฅผ ๊ฐ์ƒํ•˜์„ธ์š”.

๊ธฐ์กด Firebase ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜ CLI์—์„œ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



Example of firebase init command



โ›” ๊ณต์šฉ ํด๋”์— ์ด๋ฏธ ํŒŒ์ผ์ด ์žˆ๋Š” ๊ฒฝ์šฐ CLI์—์„œ ๋””๋ ‰ํ„ฐ๋ฆฌ ์žฌ์ •์˜๋ฅผ ์š”์ฒญํ•  ๋•Œ ์‘๋‹ตNํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์™„๋ฃŒ๋˜๋ฉด Firebase ํ”„๋กœ์ ํŠธ ๊ตฌ์„ฑ์ธ ํ”„๋กœ์ ํŠธ์— ์ƒˆ ํŒŒ์ผ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค(์ปค๋ฐ‹ํ•ด์•ผ ํ•จ).



File tree after create project



โฌ†๏ธ ๋งˆ์ง€๋ง‰์œผ๋กœ firebase deploy


Firebase deploy command with CLI





Overview of the website just deployed



Et voilร , ๊ท€ํ•˜์˜ ์‚ฌ์ดํŠธ๊ฐ€ ๋ฐฐํฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

๋„๋ฉ”์ธ ์ด๋ฆ„์˜ ๊ธฐ๋ก ๋˜๋Š” ๊ตฌ์„ฑ๊ณผ ๊ฐ™์€ ์ •๋ณด๋Š” Firebase ํ”„๋กœ์ ํŠธ ํŽ˜์ด์ง€์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



History of versions deployed on Firebase



๋ถˆ๋งŒ ๋ณธ๋‹ค



๐Ÿค” ์ œ personal website ๋ฅผ ๋ฐฐํฌํ•œ ํ›„ ์ด ๊ธ€์„ ์ž‘์„ฑํ•˜๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ, 6๊ฐœ์›”์— ํ•œ ๋ฒˆ์”ฉ ์ˆ˜์ •ํ•˜๋Š” ์‚ฌ์ดํŠธ๋ผ ์—…๋ฐ์ดํŠธ ๋ช…๋ น์–ด๋ฅผ ์ฐพ๊ธฐ๊ฐ€ ํ•ญ์ƒ ์–ด๋ ต์Šต๋‹ˆ๋‹ค.

๐Ÿ˜ ํ™•์‹คํžˆ ์ €์—๊ฒŒ ์˜ค์…จ๊ตฐ์š”. ์ด์ œ ๋ชฉํ‘œ๋Š” CI/CD ํ”„๋กœ์„ธ์Šค์—์„œ firebase deploy๋ฅผ ์ž๋™ํ™”ํ•˜์—ฌ ๋” ์ด์ƒ ๋ฐฐํฌ์— ๋Œ€ํ•ด ๊ฑฑ์ •ํ•  ํ•„์š”๊ฐ€ ์—†๊ณ  ์‹คํ–‰๋งŒ ๋ณผ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค(์˜ˆ, ์— ๋Œ€ํ•œ ๋งํฌ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์„น์…˜์˜ ์ œ๋ชฉ).
์ดˆ๊ธฐํ™” ์ค‘์— CLI๊ฐ€ ์ž๋™ ๋นŒ๋“œ ๊ตฌ์„ฑ์„ ์ œ์•ˆํ•˜๋ฉด Y ๋กœ ์‘๋‹ตํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์•ฝ๊ฐ„์˜ ์˜ต์…˜์œผ๋กœ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹คfirebase init hosting:github.

๐Ÿคซ CLI๋Š” Github Secrets ๋ฐ .yaml ํŒŒ์ผ์„ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

๋‚˜๋Š” ์ƒ์„ฑ๋œ ํŒŒ์ผ๊ณผ ๋งค์šฐ ์œ ์‚ฌํ•˜์ง€๋งŒ ๋งˆ์Šคํ„ฐ ๋ธŒ๋žœ์น˜์˜ ๊ฐ ํ‘ธ์‹œ์—์„œ ํŠธ๋ฆฌ๊ฑฐ๋˜๊ณ  "ํ”„๋กœ๋•์…˜"์— ๋ฐฐํฌ๋˜๋Š” yaml ํŒŒ์ผ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค(๋งˆ์ง€๋ง‰์œผ๋กœ ๊ฐœ์ธ ํ”„๋กœ์ ํŠธ ๋˜๋Š” POC๋ฅผ ์œ„ํ•œ ์™„๋ฒฝํ•œ ๊ตฌ์„ฑ์ž…๋‹ˆ๋‹ค).

โš ๏ธ ๋‚ด ํ”„๋กœ์ ํŠธ๊ฐ€ VueJS์— ์žˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋นŒ๋“œ ๋‹จ๊ณ„๋ฅผ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•„์š”์— ๋”ฐ๋ผ ๋ผ์ธnpm install && npm run build์„ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

name: Deploy to Firebase Hosting on push
on:
  push:
    branches: [master]

jobs:
  build_and_live:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: โฌ‡๏ธ Install dependencies and build
        run: npm install && npm run build

      - name: ๐Ÿ”ฅ Deploy to Firebase Hosting
        uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: "${{ secrets.GITHUB_TOKEN }}"
          firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_project }}"
          projectId: projectId
          channelId: "live"


โš ๏ธ ๋งˆ์ง€๋ง‰์— projectId๋ฅผ ์ˆ˜์ •ํ•˜๊ณ  service_account๋„ ์ˆ˜์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๐Ÿ™‚

โžก๏ธ ์ด์ œ ํ‘ธ์‹œํ•  ๋•Œ๋งˆ๋‹ค Github ์ž‘์—…์ด ์‹œ์ž‘๋˜๊ณ  Firebase์—์„œ ๋นŒ๋“œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.



Github Actions





History of versions deployed on Firebase



๐Ÿ“‘ ์ž์„ธํ•œ ๋‚ด์šฉ์€ Firebase ํ˜ธ์ŠคํŒ…documentation์ด ์ •๋ง ํšจ๊ณผ์ ์ž…๋‹ˆ๋‹ค!

๊ทธ๋ฆฌ๊ณ  ์ง€๊ธˆ ? ๋‚จ์€ ๊ฒƒ์€ ๋„๊ตฌ์˜ ์„ฑ๋Šฅ์„ ํ…Œ์ŠคํŠธํ•˜๋Š” ๊ฒƒ๋ฟ์ž…๋‹ˆ๋‹ค. ์•„๋งˆ๋„ ๋‹ค์Œ ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉํ•  ๊ฒƒ์ž…๋‹ˆ๊นŒ?

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ