๊ด€๋ฆฌ ๋ฉ”๋‰ด

ruriruriya

[ECR]ECR ์ƒ์„ฑ, Docker๋ฅผ ํ™œ์šฉํ•œ ์ปจํ…Œ์ด๋„ˆ ์ฒ˜๋ฆฌ์™€ AWS ์ž๋™ํ™” ๋ฐฐํฌ ๋ณธ๋ฌธ

๐Ÿ–ฅ๏ธAWS

[ECR]ECR ์ƒ์„ฑ, Docker๋ฅผ ํ™œ์šฉํ•œ ์ปจํ…Œ์ด๋„ˆ ์ฒ˜๋ฆฌ์™€ AWS ์ž๋™ํ™” ๋ฐฐํฌ

๋ฃจ๋ฆฌ์•ผใ…‘ 2023. 12. 25. 21:17
๋ฐ˜์‘ํ˜•

Docker๋ฅผ ํ™œ์šฉํ•œ ์ปจํ…Œ์ด๋„ˆ ์ฒ˜๋ฆฌ์™€ AWS์— ์ž๋™ ๋ฐฐํฌ๋ฅผ ํ•ด๋ณด์ž.

๋ณธ์ธ์€ ์„œ๋ฒ„๋ฆฌ์Šค๋กœ ์„œ๋ฒ„์— ๋ฐฐํฌํ•˜๊ณ  ์žˆ์—ˆ๊ธฐ์— ์•ž์— ๋ธ”๋กœ๊ทธ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.

https://ruriruriya.tistory.com/category/%F0%9F%93%8CServerless

 

'๐Ÿ“ŒServerless' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก

while(true){keep going studing();}

ruriruriya.tistory.com

 

๊ทธ๋ฆฌ๊ณ  ๋„์ปค๊ฐ€ ์„ค์น˜๋˜๊ณ  ํ™˜๊ฒฝ์„ค์ •์ด ๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค.

https://ruriruriya.tistory.com/201

 

[Docker] ๋„์ปค ์„ค์น˜ ๋ฐฉ๋ฒ• ๋ฐ ํ™˜๊ฒฝ์„ค์ •ํ•˜๊ธฐ

1. Docker๋ฅผ ํ™œ์šฉํ•œ ์ปจํ…Œ์ด๋„ˆ ์ฒ˜๋ฆฌ 1.1 ์šฐ์„  ๋„์ปค ํ™ˆํŽ˜์ด์ง€์—์„œ ๋„์ปค๋ฅผ ์„ค์น˜ ํ•œ๋‹ค. https://www.docker.com/ Docker: Accelerated Container Application Development Docker is a platform designed to help developers build, share, and run co

ruriruriya.tistory.com

1. Docker๋ฅผ ํ™œ์šฉํ•œ ์ปจํ…Œ์ด๋„ˆ ์ฒ˜๋ฆฌ

1.1. AWS ECR ์ƒ์„ฑ (์ €์žฅ์†Œ ๋งŒ๋“ค๊ธฐ)

1.1.1. AWS ECR ์ฝ˜์†” ์ ‘์†

https://aws.amazon.com/ko/ecr/

 

์™„์ „๊ด€๋ฆฌํ˜• ์ปจํ…Œ์ด๋„ˆ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ – Amazon Elastic Container Registry - Amazon Web Services

 

aws.amazon.com

 

1.1.2. Lambda์™€ ๊ฐ™์€ ์ด๋ฆ„์œผ๋กœ ์ง“๊ธฐ

Lambda ์™€ ๊ฐ™์€ ์ด๋ฆ„์œผ๋กœ ์ง€์–ด์•ผ ๊ด€๋ฆฌํ•˜๊ธฐ ์ข‹๋‹ค.
ex ) aws-photo-sns-app-dev // ๋’ค์— -dev.

 

1.1.3. ์œ ์ € ์ƒ์„ฑ

์œ ์ € : serverless ์„ ํƒ

์ •์ฑ… : ๋ชจ๋‘ ํ•˜๊ณ  ๋‹ค์Œ์—

์ •์ฑ…JSON ํŽธ์ง‘์œผ๋กœ ์•„๋ž˜ ์ •์ฑ… ํ•˜๋‚˜ ๋” ์ถ”๊ฐ€ํ•˜๊ธฐ
ecr:GetAuthorizationToken

- ํ•œ ๋ฒˆ ์ƒ์„ฑํ•œ ์„œ๋ฒ„๋ฆฌ์Šค ์œ ์ €๋Š” ๊ณ„์† ์“ธ ์ˆ˜ ์žˆ์Œ 

 

1.2. ๋„์ปค ์„œ๋ฒ„ ๋ฐฐํฌ ํ›„ ํ…Œ์ŠคํŠธ

1.2.1. ๋„์ปค ๋ฐ์Šคํฌํƒ‘ ์‹คํ–‰ ํ›„ sls deploy ๋ช…๋ น์–ด๋กœ ์„œ๋ฒ„ ๋ฐฐํฌ

1.2.2. ์—”๋“œํฌ์ธํŠธ url๋กœ ํฌ์ŠคํŠธ๋งจ ํ…Œ์ŠคํŠธ

 

1.2.3. AWS ECR repository ํ™•์ธ

- serverless [repository name] ์ƒ์„ฑ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ

 

2. ๋„์ปค AWS ์„œ๋ฒ„ ๋ฐฐํฌ ์ž๋™ํ™”

2.1. Docker AWS Git ์ž๋™ํ™” yml ํŒŒ์ผ ์ˆ˜์ •.

.github\workflows\main.yml ์ˆ˜์ •

name: Deploy sls app

on: 
  push:
    branches:
      - master

jobs:     
  deploy:
    runs-on: ubuntu-latest
    env:
      SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    steps:
    - uses: actions/checkout@v3
    - name: install-python
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'    
    - name: install serverless
      run: npm i -g serverless    
    - name: severless deploy
      run: sls deploy --verbose --force

 

2.2. GitHub Desktop ์—์„œ commit/push

 

 

๋ฐ˜์‘ํ˜•