swsnu / swppfall2022-team4

4 stars 1 forks source link

AWS Deployment 매뉴얼 #120

Open seuha516 opened 1 year ago

seuha516 commented 1 year ago

인스턴스 생성

고정 IP 생성

VSCode로 AWS EC2 접속

레포지토리 클론

sudo su
git clone -b release/1.2 https://github.com/swsnu/swppfall2022-team4
chmod 777 -R swppfall2022-team4/
cd swppfall2022-team4/

Docker 설치

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce

SSL 설정

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install -y python-certbot-nginx
sudo certbot certonly --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory -d 'fitogether.site' 
# Gabia에서 DNS 관리 설정, IP주소 연결
chmod -R 755 /etc/letsencrypt/live/
ls -l /etc/letsencrypt/live/fitogether.site/fullchain.pem
ls -l /etc/letsencrypt/live/fitogether.site/privkey.pem

세부사항 설정

# 백엔드 settings.py 및 프론트엔드 nginx.conf에서 IP 관련 부분 수정
# docker-compose-deployment.yml 수정
# 백엔드 Dockerfile.deployment 수정
# 프론트엔드 .env 추가

Docker 빌드

apt-get install docker-compose
docker-compose -f docker-compose-deployment.yml up -d

Docker 실행

docker exec -it backend /bin/bash
apt-get update
apt-get install redis-server -y
/etc/init.d/redis-server start
daphne -b 0.0.0.0 -p 8001 FITogether.asgi:application
docker exec -it backend /bin/bash
./run_backend.sh
docker exec -it frontend /bin/bash
./run_frontend.sh

Docker 초기화 명령어

rm -r mysqldata/
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -f "dangling=true" -q)
docker image prune -a