도커 참조
https://macaronics.net/m02/linux/view/1819
도커 설치
* 도커로 통한 젠키스 설치
https://github.com/jenkinsci/docker/blob/master/README.md
---- docker run -p 8089:8080 -p 50000:50000 --name jenkins-server --restart=on-failure -v jenkins_home:/jenkins_home jenkins/jenkins:lts-jdk17 ----
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
6526103de4944819a828e78a4167da2a
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
2023-12-04 12:01:05.552+0000 [id=51] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
2023-12-04 12:01:05.577+0000 [id=26] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
2023-12-04 12:01:06.584+0000 [id=69] INFO h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
2023-12-04 12:01:06.585+0000 [id=69] INFO hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
# 해당 컨테이너 실행
# docker exec -it jenkins-server bash
# ssb 테스트 배포 도커 서버 실행
https://hub.docker.com/r/edowon0623/docker
윈도우 11 c드라이브설정
- docker run -itd --name docker-server -p 10022:22 -e container=docker --tmpfs /run --tmpfs /tmp -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /var/run/docker.sock:/var/run/docker.sock edowon0623/docker:latest /usr/sbin/init -
비밀번호
P@ssw0rd
도커파일로 도커 실행
cat ./Dockerfile
FROM tomcat:9.0 LABEL org.opencontainers.image.authors="edowon0623@gmail.com" COPY ./hello-world.war /usr/local/tomcat/webapps
[root@711f42f604f0 ~]# docker build -t docker-in-server -f Dockerfile .
실행
--detach, -d
컨테이너를 생성하고 백그라운드에서 작동시킨다.
-d 옵션 필수
docker run -d --privileged -p 7071:8080 --name mytomcat docker-in-server:latest
확인
http://192.168.6.3:7071/hello-world/
===============================================
- 실행 명령어
- docker build --tag=cicd-project -f Dockerfile .
- docker images
- docker image inspect cicd-project:latest
- docker run -d -p 8080:8080 --name mytomcat cicd-project:latest
젠킨스 빌드 후 조치
Send build artifacts over SSH
Exec command
docker build --tag=cicd-project -f Dockerfile . ; docker run -d --privileged -p 7071:8080 --name mytomcat cicd-project:latest ;
- Windows, MacOS intel chip) Ansible 컨테이너 실행 명령어
docker run --privileged -itd --name ansible-server -p 20022:22 -p 8081:8080 -e container=docker -v /sys/fs/cgroup:/sys/fs/cgroup edowon0623/ansible:latest /usr/sbin/init 컨테이너에서 실행) vi /etc/sysconfig/docker sed -i -e 's/overlay2/vfs/g' /etc/sysconfig/docker-storage systemctl start docker systemctl status docker Windows, MacOS intel chip) Ansible 컨테이너 실행 명령어 docker run --privileged -itd --name ansible-server -p 20022:22 -p 8081:8080 -e container=docker -v /sys/fs/cgroup:/sys/fs/cgroup edowon0623/ansible:latest /usr/sbin/init 컨테이너에서 실행) vi /etc/sysconfig/docker sed -i -e 's/overlay2/vfs/g' /etc/sysconfig/docker-storage systemctl start docker systemctl status docker
Ansible
Playbook 작성
- vi first-playbook.yml
- https://github.com/joneconsulting/jenkins_cicd_script/blob/master/playbook_script/playbook-sample0.yml
- vi playbook-sample1.yml
- https://github.com/joneconsulting/jenkins_cicd_script/blob/master/playbook_script/playbook-sample1.yml
- MacOS) vi playbook-sample2.yml
- https://github.com/joneconsulting/jenkins_cicd_script/blob/master/playbook_script/playbook-sample2.yml
- Windows) vi playbook-sample2-windows.yml
- https://github.com/joneconsulting/jenkins_cicd_script/blob/master/playbook_script/playbook-sample2-windows.yml
- Linux) vi playbook-sample2-linux.yml
- https://github.com/joneconsulting/jenkins_cicd_script/blob/master/playbook_script/playbook-sample2-linux.yml
- vi first-playbook.yml
tomcat을 다운로드 받는 부분에서 checksum 처리 시 아래와 같은 오류가 발생한 경우, OS 환경에 맞는 샘플 파일로 변경해서 실행해 보시기 바랍니다.
- Tomcat 9.0.x 버전이 9.0.75 버전으로 업데이트 되었습니다.
- Tomcat 9.0.x 최신 버전은 아래 링크에서 확인하시고, 반영해 보기시 바랍니다.
- Windows 환경에서의 Playbook 실행 시 아래 파일을 사용해 주세요.
- https://github.com/joneconsulting/jenkins_cicd_script/blob/master/playbook_script/playbook-sample2-windows.yml
- Ansible-server에서 다음 명령어 ca-certificates 모듈 업데이트 필요
- yum install -y ca-certificates
- Linux 환경에서의 Playbook 실행 시 아래 파일을 사용해 주세요.
댓글 ( 4)
댓글 남기기