Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

JINIers

220623 DevOps 파이프라인 빌드(not 퀵랩) 본문

GCP/구성연습

220623 DevOps 파이프라인 빌드(not 퀵랩)

JINIers 2022. 6. 23. 12:59

퀵랩으로 연습하고 실제 프로젝트에 test 해볼 겸 설치해보았다.

 

※ 참고 : https://jiniers.tistory.com/16

 

[PCK] Building a DevOps Pipeline lab

Building a DevOps Pipeline lab DevOps 파이프라인 빌드 ※ 수정 220621 [개요] cloud sorce repositories, cloud build, build trigger 및 container registry를 사용하여 지속적 통합 파이..

jiniers.tistory.com

 


1. git 저장소 만들기

디렉토리 생성, source repository 복제

mkdir gcp-course-song
cd gcp-course-song/
gcloud source repos clone song-git-2


2. python 어플리케이션 만들기

디렉토리(templates) 및 파일 생성

song-git-2 디렉토리 내 파일 : main.py / requirements.txt

song-git-2/templates 디렉토리 내 파일 : layout.html / index.html

cd song-git-2/
vi main.py
mkdir templates
cd templates/
vi layout.html
cd gcp-course-song/
cd song-git-2/templates/
vi index.html
cd ..
vi requirements.txt

 

파일 commit & push

git add --all
git config user.email "jiyoung.song@snetsystems.co.kr"
 git config user.name "jiyoung.song"
git commit -a -m "Initial Commit"
git push origin master

파일 commit & push

 

 


설정 후
source repositories > Branch > master 파일이 전부 push 되었는지 확인

commit & push 확인


3.Dockerfile 작성


/gcp-course-song/song-git-2 에서 작업
/디렉토리/생성한 source repositories

vi Dockerfile

Dockerfile


 

4. Cloud Build 및 Container Registry로 Docker 이미지 관리

cloud build 이용 이미지 빌드

gcloud builds submit --tag gcr.io/$DEVSHELL_PROJECT_ID/devops-image:v0.1 .

이미지 빌드


container registry > images > devops-image > 이미지 확인

image build 확인

 



compute engine > create instance > container deploy > 그림과 같이 설정

 

 

container > container image > select > 설정확인

container 설정확인


 > http 체크 > 나머지 : 기본값 > create > 페이지 확인

container image 설정완성

 



git 저장소에 변경사항 저장하기

cd ~/gcp-course-song/song-git-2
git add --all
git commit -am "Added Docker Support"
git push origin master

변경사항 저장되었는지 확인


5. 트리거로 빌드 자동화

container registry > devops-image에서 이미지 확인

 

cloud build > triggers > create triggers > 
name : song-test-trigger
source
- repository : song-git-2
- branch : .*(모든분기)

나머지 : 건드리지 않는다

create trigger



container registry > 'song-git-2' > 새 이미지 확인 > 트리거 기록 보면 빌드가 되었는지 확인

빌드 되었는지 확인



vi main.py 수정 > title 속성 'hello build trigger' 변경 > 변경사항 커밋

git commit -a -m "Testing Build Trigger"
git push origin master


source repositories > history를 확인하면 새 버전이 떠 있는 걸 확인할 수 있다.

Comments