diff --git a/README.md b/README.md
index c78ff0a..23d79bc 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@
- [Docker私有仓库搭建](#docker私有仓库搭建)
- [`registry`](#registry)
- [`Harbor`](#harbor)
-- [使用 Docker 实战](#使用docker实战)
+- [使用 Docker 实战](#使用-docker-实战)
- [Docker REST API](#docker-rest-api)
- [`Nginx`](#nginx)
- [`MySQL`](#mysql)
@@ -239,10 +239,15 @@ docker run -t -i nginx:latest /bin/bash
由于国区已经无法访问,可以将镜像打包,直接安装镜像压缩文件
```sh
-$ docker pull gitlab/gitlab-ce:17.0.1-ce.0 # 下载镜像
+$ docker pull gitlab/gitlab-ce:17.2.0-ce.0 # 下载镜像
+$ docker pull --platform linux/amd64 gitlab/gitlab-ce:17.2.0-ce.0
+$ docker pull --platform linux/amd64 portainer/portainer-ce:2.20.3-alpine
+$ docker pull --platform linux/amd64 portainer/agent:2.20.3-alpine
# 保存 Docker 镜像到本地文件
$ docker save -o [output-file.tar] [image-name]
-$ docker save -o gitlab-ce-17.0.1.tar gitlab/gitlab-ce
+$ docker save -o gitlab-ce.0-17.2.0.tar gitlab/gitlab-ce:17.2.0-ce.0
+$ docker save -o portainer-agent-2.20.3-alpine.tar portainer/agent:2.20.3-alpine
+$ docker save -o portainer-ce-2.20.3-alpine.tar portainer/portainer-ce:2.20.3-alpine
```
将镜像文件发送到服务器
@@ -622,7 +627,7 @@ curl -s --unix-socket /var/run/docker.sock http://dummy/containers/json
docker info
```
-## 使用Docker实战
+## 使用 Docker 实战
> ⚠文件挂载注意:docker 禁止用主机上不存在的文件挂载到 container 中已经存在的文件
@@ -728,6 +733,10 @@ docker info
[在 docker 中部署 Navidrome](docs/navidrome.md)
+### `Jenkins`
+
+[在 docker 中部署 Jenkins](docs/jenkins/README.md)
+
### `Humpback`
首先创建放持久化数据文件夹,`mkdir -p /opt/app/humpback-web`,里面存放持久化数据文件,会存储站点管理和分组信息,启动后请妥善保存。
@@ -759,9 +768,9 @@ docker run -d --name seafile \
```shell
docker run -d --name seafile \
- -e SEAFILE_SERVER_HOSTNAME=pan.showgold.com \
- -e SEAFILE_ADMIN_EMAIL=wcj@nihaosi.com \
- -e SEAFILE_ADMIN_PASSWORD=wcj@nihaosi.com \
+ -e SEAFILE_SERVER_HOSTNAME=pan.example.com \
+ -e SEAFILE_ADMIN_EMAIL=wcj@example.com \
+ -e SEAFILE_ADMIN_PASSWORD=wcj@example.com \
-v $HOME/_docker/seafile-data:/shared \
-p 80:80 \
seafileltd/seafile:latest
diff --git a/docs/gitlab/README.md b/docs/gitlab/README.md
index dbd3ce3..77bbb04 100644
--- a/docs/gitlab/README.md
+++ b/docs/gitlab/README.md
@@ -133,6 +133,17 @@ gitlab_rails['backup_keep_time'] = 604800
docker exec 容器名或容器ID gitlab-ctl reconfigure
```
+## 备份恢复
+
+```sh
+# 从xxxxx编号备份中恢复
+# 然后恢复数据,1406691018为备份文件的时间戳
+gitlab-rake gitlab:backup:restore BACKUP=1406691018
+
+# 新版本 1721392543_2024_07_19_17.0.1_gitlab_backup.tar
+gitlab-rake gitlab:backup:restore BACKUP=1721392543_2024_07_19_17.0.1
+```
+
## 容器管理
```bash
diff --git a/docs/jenkins/Dockerfile b/docs/jenkins/Dockerfile
new file mode 100644
index 0000000..e3ba706
--- /dev/null
+++ b/docs/jenkins/Dockerfile
@@ -0,0 +1,20 @@
+FROM --platform=linux/amd64 jenkins/jenkins:2.468-jdk21
+
+# 切换到 root 用户以安装 Docker CLI
+USER root
+
+# 安装必要的软件包
+RUN apt-get update && apt-get install -y \
+ curl \
+ gnupg2 \
+ lsb-release \
+ software-properties-common
+
+# 安装特定版本的 Docker CLI
+RUN curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-26.1.4.tgz | tar xzvf - --strip-components=1 -C /usr/local/bin
+
+# 创建 docker 组并将 jenkins 用户添加到该组
+RUN groupadd docker && usermod -aG docker jenkins
+
+# 切换回 jenkins 用户
+USER jenkins
\ No newline at end of file
diff --git a/docs/jenkins/README.md b/docs/jenkins/README.md
new file mode 100644
index 0000000..cb051a6
--- /dev/null
+++ b/docs/jenkins/README.md
@@ -0,0 +1,253 @@
+Jenkins
+===
+
+下面图文示例,是通过 Docker 部署 Jenkins 并将 `Pipeline` 脚本运行在 `Docker` 中的教程,这样可以方便的使用任何版本的 `nodejs` 或者 `java` 的沙盒环境
+
+## 部署 Jenkins
+
+获取 Jenkins 和 Jenkins agent 镜像,上传到服务器
+
+```sh
+# 获取 Jenkins 镜像
+docker pull --platform linux/amd64 jenkins/jenkins:2.468-jdk21
+# 保存 Docker 镜像到本地文件
+docker save -o jenkins-2.468-jdk21.tar jenkins/jenkins:2.468-jdk21
+# 上传到服务器
+scp -P 2222 jenkins-2.468-jdk21.tar root@152.22.3.186:/home/docker-images
+
+# 获取 Jenkins agent 镜像
+docker pull --platform linux/amd64 jenkins/ssh-agent:jdk21
+docker save -o jenkins-ssh-agent-jdk21.tar jenkins/ssh-agent:jdk21
+scp -P 2222 jenkins-ssh-agent-jdk21.tar root@152.22.3.186:/home/docker-images
+```
+
+创建一个 `Dockerfile`,基于 `jenkins/jenkins:2.468-jdk21` 镜像添加 Docker 支持:
+
+```Dockerfile
+FROM --platform=linux/amd64 jenkins/jenkins:2.468-jdk21
+
+# 切换到 root 用户以安装 Docker CLI
+USER root
+
+# 安装必要的软件包
+RUN apt-get update && apt-get install -y \
+ curl \
+ gnupg2 \
+ lsb-release \
+ software-properties-common
+
+# 安装 Docker CLI
+# RUN curl -fsSL https://get.docker.com | sh
+# 安装特定版本的 Docker CLI
+RUN curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-26.1.4.tgz | tar xzvf - --strip-components=1 -C /usr/local/bin
+
+# 创建 docker 组并将 jenkins 用户添加到该组
+RUN groupadd docker && usermod -aG docker jenkins
+
+# 切换回 jenkins 用户
+USER jenkins
+```
+
+构建 jenkins 新的镜像
+
+```sh
+docker build --platform=linux/amd64 -t my-jenkins-docker-2468-jdk21 .
+# 保存 Docker 镜像为一个 tar 文件
+docker save -o my-jenkins-docker-2468-jdk21.tar my-jenkins-docker-2468-jdk21
+# 通过 SCP 传输 tar 文件到远程服务器
+scp -P 2222 my-jenkins-docker-2468-jdk21.tar root@152.22.3.186:/home/docker-images
+```
+
+```yml
+# https://github.com/jenkinsci/docker/blob/master/README.md#docker-compose-with-jenkins
+services:
+ jenkins:
+ image: my-jenkins-docker-2468-jdk21 # 自定义镜像
+ #image: jenkins/jenkins:2.468-jdk21
+ ports:
+ - "8086:8080"
+ volumes:
+ - jenkins_home:/var/jenkins_home
+ # 支持 docker
+ - /var/run/docker.sock:/var/run/docker.sock
+ ssh-agent:
+ image: jenkins/ssh-agent:jdk21
+volumes:
+ jenkins_home:
+```
+
+确保您与 `docker-compose.yml` 在同一个目录中。并启动 `Jenkins`:
+
+```sh
+docker compose up -d # 启动 Jenkins
+docker compose down # 停止并删除与 Docker Compose 配置文件相关的所有容器、网络、卷和镜像
+```
+
+访问 jenkins: http://152.22.3.186:8086/
+
+## 1. 安装插件
+
+- [Git Parameter Plug-In](https://plugins.jenkins.io/git-parameter) 支持在 CI 上自动加载仓库分支
+
+## 2. 添加凭证
+
+
+
+
+
+
+
+
+
+## 3. 新建工作流
+
+
+
+修改配置
+
+
+
+
+设置 [`Git Parameter`](https://plugins.jenkins.io/git-parameter) 可以在构建的时候读取分支,选择分支
+
+
+
+
+
+## 3. 添加构建选项,可以在构建前选择 `生产` 还是 `开发` 模式,在脚本中判断
+
+
+
+## 4. 选择 `Pipeline script from SCM` 指定脚本位置
+
+
+
+这方法是将 仓库 `config` 分支添加一个 `Jenkinsfile` 配置
+
+## Nodejs
+
+安装 [Docker Pipeline](https://plugins.jenkins.io/git-parameter) 插件,支持从管道中构建和使用 `Docker` 容器。
+
+```sh
+docker pull --platform linux/amd64 node:14.16.0
+docker pull --platform linux/amd64 node:18
+docker pull --platform linux/amd64 node:20
+docker pull --platform linux/amd64 node:22
+
+# 保存 Docker 镜像到本地文件
+docker save -o node14.16.tar node:14.16.0
+# 上传到服务器
+scp -P 2222 node14.16.tar root@152.22.3.186:/home/docker-images
+
+docker save -o node18.tar node:18
+scp -P 2222 node18.tar root@152.22.3.186:/home/docker-images
+
+docker save -o node20.tar node:20
+scp -P 2222 node20.tar root@152.22.3.186:/home/docker-images
+
+docker save -o node22.tar node:22
+scp -P 2222 node22.tar root@152.22.3.186:/home/docker-images
+```
+
+Pipeline 脚本中使用 Docker nodejs 20 运行
+
+```groovy
+pipeline {
+ //agent any
+ // pipeline 放到 docker 中执行
+ agent {
+ docker {
+ // 使用 Node.js 18 的 Docker 镜像
+ image 'node:20'
+ // 可选:挂载 NPM 缓存目录,加速构建
+ args '-v /root/.npm:/root/.npm'
+ }
+ }
+ environment {
+ def git_url="http://152.22.3.186:8081/mall/h5.git"
+ def git_auth = "12312312-f199-4b15-b087-123123"
+ def git_branch = "${branch}"
+ def project_env = "${project_env}"
+ def data_dir = "/mnt/mall/h5/h5_vip"
+
+ // 本地需要上传的目录 以及远程服务器的目录
+ def localDir = "${WORKSPACE}/h5_vip/test_dir/"
+ def vip_host = '106.53.119.240'
+ def vip_remote_dir = "/mnt/mall/h5"
+ }
+ stages {
+ stage('Git Checkout'){
+ steps {
+ echo "🏆 WORKSPACE: 【${WORKSPACE}】"
+ echo "🎯 branch: 【${git_branch}】"
+ echo "🏅 project_env: 【${project_env}】"
+ echo 'check git'
+ checkout([
+ $class: 'GitSCM',
+ branches: [[name: "${git_branch}" ]],
+ doGenerateSubmoduleConfigurations: false,
+ extensions: [],
+ submoduleCfg: [],
+ userRemoteConfigs: [[
+ credentialsId: "${git_auth}",
+ url: "${git_url}"
+ ]]
+ ])
+ sh 'pwd'
+ sh 'ls -la'
+ }
+ }
+ }
+ stage('Send Files') {
+ when {
+ expression {
+ currentBuild.result == null || currentBuild.result == 'SUCCESS'
+ }
+ }
+ steps {
+ sh 'pwd'
+ script{
+ switch (project_env) {
+ case "vip":
+ sh '''
+ ls -la
+ cd h5_vip
+ npm install --registry=https://registry.npmmirror.com/
+ ls -la
+ npm run build
+ ls -la
+ rm -rf test_dir
+ mv dist test_dir
+ '''
+ withCredentials([sshUserPrivateKey(credentialsId: 'bd6f00e6-9dfd-4fd5-b94b-7559ca212e9a', keyFileVariable: 'SSH_KEY')]) {
+ // 连接到远程服务器并删除 test_dir 目录 重新上传
+ sh '''
+ ssh -i ${SSH_KEY} -o StrictHostKeyChecking=no root@106.53.119.240 "rm -rf /mnt/mall/h5/test_dir"
+ scp -i ${SSH_KEY} -o StrictHostKeyChecking=no -P 22 -r "${localDir}" root@106.53.119.240:${vip_remote_dir}
+ '''
+ }
+ break
+ case "dev":
+ // for (i in ['152.22.3.186']) {
+ // data_dir = "/mnt/mall/h5/"
+ // //sh "ssh $i 'cp -rf ${data_dir}/* ${data_dir}/h5_vip_{uuid_no}'"
+ // sh "scp -r -o StrictHostKeyChecking=no -i /var/lib/jenkins/.ssh/id_rsa -P 22 '${WORKSPACE}/h5_vip/' '$i:${data_dir}'"
+ // }
+ break
+
+ }
+ }
+ }
+ }
+ }
+ post {
+ success {
+ sh "echo 'Success success'"
+ }
+
+ failure {
+ sh "echo 'Faild faild'"
+ }
+ }
+}
+```
\ No newline at end of file
diff --git a/docs/jenkins/imgs/1.png b/docs/jenkins/imgs/1.png
new file mode 100644
index 0000000..8ce52f1
Binary files /dev/null and b/docs/jenkins/imgs/1.png differ
diff --git a/docs/jenkins/imgs/10.png b/docs/jenkins/imgs/10.png
new file mode 100644
index 0000000..c1d4f26
Binary files /dev/null and b/docs/jenkins/imgs/10.png differ
diff --git a/docs/jenkins/imgs/2.png b/docs/jenkins/imgs/2.png
new file mode 100644
index 0000000..6537642
Binary files /dev/null and b/docs/jenkins/imgs/2.png differ
diff --git a/docs/jenkins/imgs/3.png b/docs/jenkins/imgs/3.png
new file mode 100644
index 0000000..26e7c03
Binary files /dev/null and b/docs/jenkins/imgs/3.png differ
diff --git a/docs/jenkins/imgs/4.png b/docs/jenkins/imgs/4.png
new file mode 100644
index 0000000..c477f44
Binary files /dev/null and b/docs/jenkins/imgs/4.png differ
diff --git a/docs/jenkins/imgs/5.png b/docs/jenkins/imgs/5.png
new file mode 100644
index 0000000..9cf4f41
Binary files /dev/null and b/docs/jenkins/imgs/5.png differ
diff --git a/docs/jenkins/imgs/6.png b/docs/jenkins/imgs/6.png
new file mode 100644
index 0000000..9585794
Binary files /dev/null and b/docs/jenkins/imgs/6.png differ
diff --git a/docs/jenkins/imgs/7.png b/docs/jenkins/imgs/7.png
new file mode 100644
index 0000000..e90403a
Binary files /dev/null and b/docs/jenkins/imgs/7.png differ
diff --git a/docs/jenkins/imgs/8.png b/docs/jenkins/imgs/8.png
new file mode 100644
index 0000000..8ec6e69
Binary files /dev/null and b/docs/jenkins/imgs/8.png differ
diff --git a/docs/jenkins/imgs/9.png b/docs/jenkins/imgs/9.png
new file mode 100644
index 0000000..dd880e9
Binary files /dev/null and b/docs/jenkins/imgs/9.png differ
diff --git a/docs/portainer.md b/docs/portainer.md
index 12700d7..f829fbd 100644
--- a/docs/portainer.md
+++ b/docs/portainer.md
@@ -30,7 +30,7 @@ curl -L https://downloads.portainer.io/ee2-18/portainer-agent-stack.yml -o porta
docker stack deploy -c portainer-agent-stack.yml portainer
```
-## v1.22x
+## v2.20
新建 `portainer-agent-stack.yml` 文件, 将下面内容复制到配置文件中,你可以从官方仓库拷贝 [`portainer/portainer-compose`](https://github.com/portainer/portainer-compose) 配置。
@@ -38,17 +38,11 @@ docker stack deploy -c portainer-agent-stack.yml portainer
version: '3.2'
services:
agent:
- image: portainer/agent
- environment:
- # REQUIRED: Should be equal to the service name prefixed by "tasks." when
- # deployed inside an overlay network
- AGENT_CLUSTER_ADDR: tasks.agent
- # AGENT_PORT: 9001
- # LOG_LEVEL: debug
+ image: portainer/agent:2.20.3-alpine
volumes:
- /var/run/docker.sock:/var/run/docker.sock
+ #- ${HOME}/.orbstack/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
- - /etc/localtime:/etc/localtime:ro
networks:
- agent_network
deploy:
@@ -57,10 +51,12 @@ services:
constraints: [node.platform.os == linux]
portainer:
- image: portainer/portainer
+ image: portainer/portainer-ce:2.20.3-alpine
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
+ - "9443:9443"
- "9000:9000"
+ - "8000:8000"
volumes:
- portainer_data:/data
- /etc/localtime:/etc/localtime:ro