CI/CD 가 구성이 잘 됐다면, 소스코드가 수정됐을때 개발자 도구가 자동으로 감지하여 빌드하고, 빌드된 애플리케이션을 자동으로 감지하여 인프라에 자동으로 애플리케이션을 배포하게 된다.
root@ubuntu:~# apt-get -y install lrzsz
패키지의 도움을 받아 zip 파일을 드래그하여 파일 전송
awscode 레포지토리에 커밋
root@ubuntu:~# unzip awstest-main.zip
Archive: awstest-main.zip
f1211c2bd2ad873c3ea0982e41299accd67be188
creating: awstest-main/
inflating: awstest-main/appspec.yml
inflating: awstest-main/buildspec.yml
extracting: awstest-main/index.html
creating: awstest-main/scripts/
inflating: awstest-main/scripts/server_start.sh
inflating: awstest-main/scripts/server_stop.sh
inflating: awstest-main/test.jsp
root@ubuntu:~# ls
ansible aws awscliv2.zip awstest-main awstest-main.zip ecs snap
root@ubuntu:~# cd awstest-main/
root@ubuntu:~/awstest-main# ls
appspec.yml buildspec.yml index.html scripts test.jsp
<로컬 레포지토리 초기화>
root@ubuntu:~/awstest-main# git init
Initialized empty Git repository in /root/awstest-main/.git/
root@ubuntu:~/awstest-main# git config --global user.email "euijoo@gmail.com"
root@ubuntu:~/awstest-main# git config --global user.name "Leeeuijooo"
root@ubuntu:~/awstest-main# ls
appspec.yml buildspec.yml index.html scripts test.jsp
root@ubuntu:~/awstest-main# git add .
root@ubuntu:~/awstest-main# git commit -m "first commit"
[master (root-commit) 5ae5ad5] first commit
6 files changed, 67 insertions(+)
create mode 100644 appspec.yml
create mode 100644 buildspec.yml
create mode 100644 index.html
create mode 100644 scripts/server_start.sh
create mode 100644 scripts/server_stop.sh
create mode 100644 test.jsp
root@ubuntu:~/awstest-main# git branch -M main
root@ubuntu:~/awstest-main# git push -u origin main
Username for 'https://github.com': Leeeuijooo
Password for 'https://Leeeuijooo@github.com':
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 2 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 1.33 KiB | 1.33 MiB/s, done.
Total 9 (delta 0), reused 0 (delta 0)
To https://github.com/Leeeuijooo/awscode
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'
[ec2-user@ip-10-10-1-113 ~]$ sudo yum -y install ruby
[ec2-user@ip-10-10-1-113 ~]$ wget https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/latest/install
[ec2-user@ip-10-10-1-113 ~]$ sudo chmod +x ./install
[ec2-user@ip-10-10-1-113 ~]$ sudo ./install auto
[ec2-user@ip-10-10-1-113 ~]$ sudo systemctl restart codedeploy-agent
[ec2-user@ip-10-10-1-113 ~]$ sudo systemctl enable codedeploy-agent
<빌드 절차 파일 : buildspec>
version: 0.2
phases:
install:
runtime-versions:
java: corretto17 # 자바 버전을 설치
build: # 빌드를 하고 나서 어떤 행동을 할 것인지 현재 상태에는 빌드할 내용이 없다
commands:
- echo Building
post_build: # 빌드가 끝나고 나서
commands:
## aws s3 cp target/*.war s3://myhhbucket23 . We don't need this step.
- echo Build completed
artifacts: # 서버에 올라갈 파일들을 명시한다.
files:
- test.jsp
# - index.html
- scripts/server_start.sh
- scripts/server_stop.sh
- appspec.yml
discard-paths: yes # 파일의 경로를 무시하겠다.
[ec2-user@ip-10-10-1-113 ~]$ ls /opt/codedeploy-agent/deployment-root/
ab707106-ee73-42e1-835c-b777a8144ca6 deployment-instructions deployment-logs ongoing-deployment
[ec2-user@ip-10-10-1-113 ~]$ ls /opt/codedeploy-agent/deployment-root/ab707106-ee73-42e1-835c-b777a8144ca6/
d-6EK75XI3L d-MPNURSI3L
[ec2-user@ip-10-10-1-113 ~]$ ls /opt/codedeploy-agent/deployment-root/ab707106-ee73-42e1-835c-b777a8144ca6/d-6EK75XI3L/
bundle.tar deployment-archive logs
[ec2-user@ip-10-10-1-113 ~]$ ls /opt/codedeploy-agent/deployment-root/ab707106-ee73-42e1-835c-b777a8144ca6/d-6EK75XI3L/deployment-archive/
appspec.yml index.html server_start.sh server_stop.sh test.jsp