[Docker] - 젠킨스 CI/CD (2) - 실습

김인회·2022년 4월 18일
0

OTT프로젝트

목록 보기
6/6
post-thumbnail

📖 젠킨스 서버(컨테이너)환경 및 Jobs 구성 요약

Jenkins Version : Jenkins 2.332.2
(Docker Img : jenkins/jenkins:lts - https://hub.docker.com/r/jenkins/jenkins)

Installed App : Docker version 20.10.14, build a224086

-Jenkins Jobs-

Build Trigger : GitHub hook trigger for GITScm polling

Build Process: Maven targets -> Shell script

⚙ CI/CD 과정 요약

Github push (Web Hook) -> Clone source from Github repository (To Jenkins)

-> Package as War (On Jenkins's Maven) -> Build Docker's Tomcat Img (From new source)

-> Run Tomcat (With new WAR)

⚙ 젠킨스 컨테이너 구동 정보

docker run -d --name myjenkins \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v jenkins:/var/jenkins_home \
    -p 8080:8080  \
    -u root \
    -d jenkins/jenkins:lts

⚙ 톰캣 컨테이너 DockerFile

FROM tomcat:9.0.58
LABEL maintainer="inhoe.kim95@gmail.com"
ENV TZ=Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN rm -Rf /usr/local/tomcat/webapps/ROOT
RUN rm /usr/local/tomcat/conf/server.xml
COPY server.xml /usr/local/tomcat/conf/
COPY FinalPrj/target/final-1.0.0-BUILD-SNAPSHOT.war /usr/local/tomcat/webapps/ott.war
EXPOSE 80
CMD ["catalina.sh", "run"]

⚙ 젠킨스 Build Process - Script Shell

#!/bin/sh
cd /var/jenkins_home/workspace/OTT #Docker 파일이 존재하는 경로
docker rm  -f mytomcat || true
docker build -t mytomcatimg .
docker run -d -p 80:80 --name mytomcat mytomcatimg
profile
안녕하세요. 잘부탁드립니다.

0개의 댓글