制品库
配置 | 技术栈 | 类型 | 标签 |
---|---|---|---|
2核4G | Jenkins + Nexus + Docker | Cloud | 构建机 |
2核4G | Docker + Kubernetes | Cloud | kubernetes Master |
1核1G | Docker + Kubernetes | Cloud | kubernetes Node |
yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce -y
systemctl start docker
systemctl enable docker
配置阿里云镜像源
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://fwvjnv59.mirror.aliyuncs.com"]
}
EOF
# 重载所有修改过的配置文件
sudo systemctl daemon-reload
sudo systemctl restart docker
yum install git -y
yum install -y java
sudo wget -O /etc/yum.repos.d/jenkins.repo https://img.zhufengpeixun.com/jenkins.repo
sudo rpm --import https://img.zhufengpeixun.com/jenkins.io.key
yum install jenkins -y
systemctl start jenkins.service
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=50000/tcp --permanent
systemctl reload firewalld
http://8.136.218.128:8080/
cat /var/lib/jenkins/secrets/initialAdminPassword
sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' /var/lib/jenkins/updates/default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' /var/lib/jenkins/updates/default.json
sudo gpasswd -a jenkins docker #将当前用户添加至docker用户组
newgrp docker #更新docker用户组
docker -v
docker pull node:latest
Provide Node & npm bin/ folder to PATH
默认会拉取这个地址的安装包,但有可能会失败,失败之后可以重复,这个只需要执行一次就可以了
Unpacking https://nodejs.org/dist/v15.11.0/node-v15.11.0-linux-x64.tar.gz to /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs15.11.0 on Jenkins
ssh-keygen -t rsa -C "zhufengnodejs@126.com"
cat ~/.ssh/id_rsa.pub
yum install git -y
Dockerfile
FROM nginx:1.15
COPY build /etc/nginx/html
COPY conf /etc/nginx/
WORKDIR /etc/nginx/html
conf\site
server {
listen 80;
server_name _;
root /etc/nginx/html;
}
#!/bin/sh
npm install --registry=https://registry.npm.taobao.org
npm run build
docker build -t react-project .
cd /usr/local
wget https://dependency-fe.oss-cn-beijing.aliyuncs.com/nexus-3.29.0-02-unix.tar.gz
tar -zxvf ./nexus-3.29.0-02-unix.tar.gz
cd nexus-3.29.0-02/bin
./nexus start
firewall-cmd --zone=public --add-port=8081/tcp --permanent
firewall-cmd --zone=public --add-port=8082/tcp --permanent
http://8.136.218.128:8081/
nexus 还支持停止,重启等命令。可以在 bin 目录下执行 ./nexus help 查看更多命令
cat /root/sonatype-work/nexus3/admin.password
登录 => 齿轮图标 => Repositories => Create repository => docker(hosted) => HTTP(8082)
proxy: 此类型制品库原则上只下载,不允许用户推送
vi /etc/docker/daemon.json
{
"insecure-registries" : [
"8.136.218.128:8082"
],
"registry-mirrors": ["https://fwvjnv59.mirror.aliyuncs.com"]
}
systemctl restart docker
docker login 8.136.218.128:8082 //注意此处要和insecure-registries里的地址一致
Username: admin
Password: 123456
Username with password
,输入用户名和密码然后点添加确定#!/bin/sh -l
npm install --registry=https://registry.npm.taobao.org
npm run build
docker build -t 8.136.218.128:8082/react-project .
docker login -u $DOCKER_LOGIN_USERNAME -p $DOCKER_LOGIN_PASSWORD 8.136.218.128:8082
docker push 8.136.218.128:8082/react-project