CI - Docker image
CI
docker build
[ nginx 어플리케이션으로 docker image을 빌드 합니다. ]
1. docker 설치
2. index.html 파일 생성
> index.html 파일은 nginx에서 사용할 파일이다.
> nginx docker image 빌드할때 nginx안에 index.html 파일을 복사할 용도로 생성한다.
# mkdir build
# cd build
# vi index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p> ekstest - nginx1 </p>
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
3. dockerfile 파일 생성
> dockerfile은 docker image을 생성할 때 어떻게 build할지 정의하는 파일이다.
# vi dockerfile
> docker build은 dockerfile에 정의된 내용으로 docker image을 생성한다.
# curl localhost:8300
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 계정account.dkr.ecr.ap-northeast-2.amazonaws.com
> docker 이미지 업로드 하기전에 AWS ECR 로그인
docker tag nginx-test:0.1 계정account.dkr.ecr.ap-northeast-2.amazonaws.com/ekstest1:latest
> docker 이미지를 AWS ECR repository 주소에 맞게 변경 / tag 변경
docker push 계정account.dkr.ecr.ap-northeast-2.amazonaws.com/ekstest1:latest
> docker 이미지를 AWS ECR repository에 업로드
5. pod 배포
kubectl run nginx --image 계정account.dkr.ecr.ap-northeast-2.amazonaws.com/ekstest1:latest --port=80 -ndw
curl pod IP:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p> ekstest - nginx1 </p>
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>