728x90
반응형
Nexus
https://hub.docker.com/r/sonatype/nexus3/
https://velog.io/@king/private-docker-registry
sudo docker pull sonatype/nexus3:3.34.1
sudo docker run -d -p 8081:8081 -p 5000:5000 --name demo-nexus sonatype/nexus3:3.34.1
sudo docker exec -it demo-nexus bash
> cat /nexus-data/admin.password
Nexus 세팅
docker-hosted, docker-hub 추가
repo-docker-hosted 추가
docker-hub 추가
nexus 연동
# docker http
sudo vi /etc/docker/daemon.json
{
"insecure-registries" : ["localhost:5000"]
}
# docker hub login
docker login localhost:5000
nexus docker hub 테스트
# docker hub push
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sonatype/nexus3 3.34.1 8a9245af1b06 2 days ago 655MB
redis latest 02c7f2054405 3 weeks ago 105MB
jenkins/jenkins lts-jdk11 619aabbe0502 4 weeks ago 441MB
# docker tag
docker tag 619aabbe0502 localhost:5000/jenkins/jenkins:20210925
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sonatype/nexus3 3.34.1 8a9245af1b06 2 days ago 655MB
redis latest 02c7f2054405 3 weeks ago 105MB
jenkins/jenkins lts-jdk11 619aabbe0502 4 weeks ago 441MB
localhost:5000/jenkins/jenkins 20210925 619aabbe0502 4 weeks ago 441MB
docker push localhost:5000/jenkins/jenkins:20210925
# docker hub pull
docker pull localhost:5000/jenkins/jenkins:20210925
연동
### Docker 테스트
cd /home
git clone https://github.com/sanggi-wjg/flask-jwt-demo.git
cd /flask-jwt-demo
docker build -t flask-jwt .
#docker run -d -p 8085:8085 --name flask-jwt flask-jwt
jenkins nexus docker hub credential 추가
배포 결과
Jenkins pipeline
production, alpha 등 환경에서는 소스 커밋이나 머지시에 한개 파이프라인에서 빌드해서
nexus에 push 하고 다른 파이프라인에서는 nexus에서 pull 받아서 배포하고 그런식으로 하면 될듯?
node {
withCredentials([[$class: 'UsernamePasswordMultiBinding',
credentialsId: 'nexus-docker-hub2',
usernameVariable: 'DOCKER_USER_ID',
passwordVariable: 'DOCKER_USER_PASSWORD'
]])
{
stage('Git Checkout')
{
git branch: 'main',
url: 'https://github.com/sanggi-wjg/flask-jwt-demo.git'
}
stage('Build')
{
sh "docker build -t ${DOCKER_USER_ID}/flask-jwt ."
}
stage('Tag')
{
sh "docker login localhost:5000 -u ${DOCKER_USER_ID} -p ${DOCKER_USER_PASSWORD}"
//sh "docker tag ${DOCKER_USER_ID}/flask-jwt ${DOCKER_USER_ID}/flask-jwt:${BUILD_NUMBER}"
sh "docker tag ${DOCKER_USER_ID}/flask-jwt localhost:5000/flask-jwt:${BUILD_NUMBER}"
}
stage('Push')
{
//sh "docker push ${DOCKER_USER_ID}/flask-jwt:${BUILD_NUMBER}"
//sh "docker push ${DOCKER_USER_ID}/flask-jwt:latest"
sh "docker push localhost:5000/flask-jwt:${BUILD_NUMBER}"
}
stage('Run') {
sh "docker run -d -p 8085:8085 --name flask-jwt localhost:5000/flask-jwt:${BUILD_NUMBER}"
}
}
}
728x90
반응형
'IT' 카테고리의 다른 글
WEB RTC (0) | 2021.09.27 |
---|---|
JWT (JSON Web Token) (0) | 2021.09.27 |
[Jenkins] 젠킨스 Dockerfile 설치 (0) | 2021.02.08 |
[Jenkins] 젠킨스란 무엇인가 (0) | 2021.02.05 |
소프트웨어 개발원칙 YAGNI (0) | 2021.01.22 |