# [AWS] AWS instance(EC2) 에 Docker image 배포

2024. 12. 13. 16:16개발/클라우드


본 포스팅은 AWS 에 Docker image 를 배포(push-pull) 하는 내용을 다룹니다.

🌞 2024.12.13 Fri

1. AWS 간단 설명

  • AWS instance 시작. 리전, 키패어, 보안그룹(http, ssh 유형 위치무관), 스토리지 볼륨 30G, 모니터링,
  • 고정아이피 = 탄력적아이피 설정(ec2 중지 하면 ip 가 사라진다. ip 유지 )

2. EC2 ACCESS 후 업데이트 및 node 설치

    # 🧿🧿🧿 << Command line interface>> 🧿🧿🧿
    sudo root passwd 
    su
    ## 주요 file update & Seting 
    apt-get update && /
    apt-get install -y ca-certificates curl gnupg && /
    mkdir -p /etc/apt/keyrings && /
    curl -fsSL <https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key> | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && /
    NODE_MAJOR=20 && /
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] <https://deb.nodesource.com/node_$NODE_MAJOR.x> nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list && /
    apt-get update && /
    apt-get install nodejs -y && /
    apt-get install tree && /
    node -v

    ## Express example git down and nmp install
    git clone https://github.com/JSCODE-EDU/ec2-express-sample
    ls
    ## npm install 
    npm i
    cd ec2-express-sample
    ## npm .env file 관리 
    vi .env
        DATABASE_NAME=my_database

3. pm 2 설치 하여 서버 실행

    npm i -g pm2
    pm2 start app.js
  • aws public ip 를 크롬 주소 창에 입력해 들어가서 페이지 확인