harbor(私有dockerhub) gitlab Jenkins nginx 搭建日记
我都是在docker的基础上搭建的,前提安装docker 和 docker-compose
安装docker省略掉
docker-compose安装
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
1.harbor下载
tar -xvf harbor-offline-installer-v2.1.0.tgz
cd harbor
cp harbor.yml.tmpl harbor.yml
vi harbor.yml
#修改以下内容
hostname = 127.0.0.1 #设置启动ip,如果是外网访问需要设置外网ip
port: 80 #端口
harbor_admin_password = admin #设置admin用户的密码
data_volume: /data/harbor #设置存储位置
#然后保存后开始构建
./prepare
./install.sh
docker ps #看看有没有启动成功
2.安装gitlab 编写docker-compose 运行GITLAB_OMNIBUS_CONFIG配置参照官网
gitlab:
image: "gitlab/gitlab-ce:latest"
restart: always
hostname: "gitlab.dust.com"
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.dust.com:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = 'smtp.qq.com'
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = '****@qq.com'
gitlab_rails['smtp_password'] = 'elpukadqpvyfebhe'
gitlab_rails['smtp_domain'] = 'qq.com'
gitlab_rails['smtp_authentication'] = 'login'
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '****@qq.com'
alertmanager['admin_email'] = '****@outlook.com'
ports:
- "8929:8929"
- "2224:22"
volumes:
- "/data/gitlab/config:/etc/gitlab"
- "/data/gitlab/logs:/var/log/gitlab"
- "/data/gitlab/data:/var/opt/gitlab"
3.安装Jenkins
docker container run \
--name jenkins-blueocean \
--detach \
--network jenkins \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client \
--env DOCKER_TLS_VERIFY=1 \
--publish 8085:8080 \
--publish 8086:50000 \
--volume /data/jenkins-data:/var/jenkins_home \
--volume /data/jenkins-docker-certs:/certs/client:ro \
jenkinsci/blueocean
#设置文件夹的权限
chown -R 1000 /data/jenkins-data
chown -R 1000 /data/jenkins-docker-certs
#重启容器
docker stop jenkins-blueocean
docker start jenkins-blueocean
4.nginx 部署
docker run -d --name nginx -p 80:80 -p 443:443 nginx
查看存放目录docker exec -it nginx /bin/bash
日志文件位置:/var/log/nginx
配置文件位置: /etc/nginx
资源存放的位置: /usr/share/nginx/html
docker cp nginx:/var/log/nginx $pwd/logs
docker cp nginx:/etc/nginx $pwd/conf
docker cp nginx:/usr/share/nginx/html $pwd/html
docker stop nginx
docker rm nginx
docker run -d --name nginx -p 80:80 -p 443:443 `
-v $pwd/conf:/etc/nginx `
-v $pwd/html:/usr/share/nginx/html `
-v $pwd/logs:/var/log/nginx `
nginx