启动后端相关的容器
nexus、gitlab、jenkins
version: "3"
services:
# nexus
# docker-compose run nexus "id" # 查看容器内nexus 所属的用户和用户组,或者去dockerhub 上面去看看这个容器的构建记录(IMAGE LAYERS),看看设置的uid gid是多少
# mkdir -p /opt/data/nexus/nexus-data && chown -R 200:200 /opt/data/nexus/nexus-data # 不管宿主机有没有这个用户和用户组你设置就肯定能行
nexus:
image: sonatype/nexus3:3.30.0
ports:
- 8081:8081
volumes:
- /opt/data/nexus/nexus-data:/nexus-data
environment:
- INSTALL4J_ADD_VM_PARAMS=-Xms1g -Xmx1g -XX:MaxDirectMemorySize=1g
- NEXUS_CONTEXT=nexus
container_name: nexus
restart: always
networks:
- back-net
# gitlab
gitlab:
image: gitlab/gitlab-ce:13.7.4-ce.0
container_name: gitlab
ports:
- 4433:443
- 88:80
- 222:22
volumes:
- /opt/data/gitlab/config:/etc/gitlab
- /opt/data/gitlab/logs:/var/log/gitlab
- /opt/data/gitlab/data:/var/opt/gitlab
restart: always
networks:
- back-net
# rabbitmq
rabbitmq:
image: rabbitmq:3-management
container_name: rabbitmq
ports:
- 5672:5672
- 15672:15672
restart: always
networks:
- back-net
# redis
back_redis:
image: redis:6.2.1-buster
container_name: back_redis
ports:
- 6379:6379
volumes:
- /opt/data/redis/data:/data
- /opt/data/redis/conf:/etc/redis
restart: always
networks:
- back-net
# jenkins
# mkdir -p /opt/data/jenkins/jenkins_home && chown -R 1000:1000 /opt/data/jenkins/jenkins_home
jenkins:
image: jenkins/jenkins:2.277.1-lts-centos7
container_name: jenkins
ports:
- 8080:8080
- 50000:50000
volumes:
- /opt/data/jenkins/jenkins_home:/var/jenkins_home
restart: always
networks:
- back-net
# # nginx
# back_nginx:
# image: nginx:1.19.8
# container_name: back_nginx
# restart: always
# ports:
# - 80:80
# volumes:
# - /opt/data/nginx/static_resource:/usr/share/nginx/html
# - /opt/data/nginx/nginx.conf:/host/path/nginx.conf
# # restart: always
# networks:
# - back-net
networks:
back-net:
driver: bridge
安装
#!/bin/bash
# install.sh
# 创建目录
mkdir -p /opt/data/nexus/nexus-data && chown -R 200:200 /opt/data/nexus/nexus-data
mkdir -p /opt/data/jenkins/jenkins_home && chown -R 1000:1000 /opt/data/jenkins/jenkins_home
# 运行运行docker-compose
docker-compose -f docker-compose.yml up -d
# 运行harbor(需要去修改harbor.yml,修改./barbor/install.sh,然后执行./barbor/install.sh)
# 修改名字,下次就别在加载了
# if [ ! -d back ]
# then
# mkdir back
# mv harbor.*.tar.gz ./back
# fi
bash ./harbor/install.sh
echo "修改/etc/docker/daemon.json文件加上。{ "insecure-registries":["harbor-hostname:port"] } "
启动停止脚本
#!/bin/bash
# cicd
if [[ $1 = "start" ]];then
docker-compose -f ./docker-compose.yml start
docker-compose -f ./harbor/docker-compose.yml start
echo "启动cicd相关容器"
elif [[ $1 = "stop" ]];then
docker-compose -f ./docker-compose.yml stop
docker-compose -f ./harbor/docker-compose.yml stop
echo "停止cicd相关容器"
elif [[ $1 = "install" ]];then
/bin/bash ./install.sh
elif [[ $1 = "down" ]]; then
docker-compose -f ./docker-compose.yml down
docker-compose -f ./harbor/docker-compose.yml down
echo "删除所有的容器"
else
echo "运行方式是 xx [start|stop]"
fi