Skip to content

Commit

Permalink
🎨 docker
Browse files Browse the repository at this point in the history
  • Loading branch information
oddfar committed Jun 6, 2021
1 parent 857e19d commit 0e24188
Show file tree
Hide file tree
Showing 7 changed files with 556 additions and 63 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ jobs: # 工作流
with:
node-version: ${{ matrix.node-version }} # 版本
#-------------------------------------------------------------------
- name: Configure Private Key #★★★★★★步骤3:设置ssh
- name: Configure Private Key #★★★★★★ 步骤3:设置ssh ★★★★★★
env:
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} # gitee的ssh
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "StrictHostKeyChecking no" >> ~/.ssh/config
- name: Push Gitee Mirror #★★★★★★步骤4:推送到gitee
- name: Push Gitee Mirror #★★★★★★ 步骤4:推送到gitee★★★★★★
env:
SOURCE_REPO: 'https://github.com/oddfar/notes.git'
DESTINATION_REPO: '[email protected]:oddfar/notes.git'
SOURCE_REPO: 'https://github.com/oddfar/notes.git' #github 仓库地址
DESTINATION_REPO: '[email protected]:oddfar/notes.git' #gitee 仓库地址
run: |
git clone --mirror "$SOURCE_REPO" && cd `basename "$SOURCE_REPO"`
git remote set-url --push origin "$DESTINATION_REPO"
Expand Down
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
- [准备](#%E5%87%86%E5%A4%87)
- [写作](#%E5%86%99%E4%BD%9C)
- [部署](#%E9%83%A8%E7%BD%B2)
- [手动部署到github](#%E6%89%8B%E5%8A%A8%E9%83%A8%E7%BD%B2%E5%88%B0github)
- [自动部署到github](#%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2%E5%88%B0github)
- [手动部署到 GitHub](#%E6%89%8B%E5%8A%A8%E9%83%A8%E7%BD%B2%E5%88%B0-github)
- [自动部署到 GitHub](#%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2%E5%88%B0-github)
- [部署到自己服务器](#%E9%83%A8%E7%BD%B2%E5%88%B0%E8%87%AA%E5%B7%B1%E6%9C%8D%E5%8A%A1%E5%99%A8)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

使用[vuepress](https://vuepress.vuejs.org/zh)搭建,自动部署在[GitHub Pages](https://pages.github.com/)

使用[vdoing](https://github.com/xugaoyi/vuepress-theme-vdoing)主题
使用 [vuepress](https://vuepress.vuejs.org/zh) 搭建,自动部署在[GitHub Pages](https://pages.github.com/)

## 准备

Expand All @@ -22,7 +20,7 @@ VuePress 需要 [Node.js ](https://nodejs.org/en/)>= 8.6
1. 克隆到本地并进入目录

```sh
git clone https://github.com/oddfar/docs.git && cd docs
git clone https://github.com/oddfar/notes.git && cd notes
```

2. 安装本地依赖
Expand All @@ -37,13 +35,13 @@ VuePress 需要 [Node.js ](https://nodejs.org/en/)>= 8.6
npm run dev
```

默认访问链接:http://localhost:8080/doc
默认访问链接:http://localhost:8080/

## 写作

使用`markdown`语法编写`md`文件,所有笔记`md`文件放在`docs/docs`目录下
使用 `markdown` 语法编写`md`文件,所有笔记 `md` 文件放在 `docs/` 目录下

例如添加`test`类,并编写`hello.md`文件
例如添加 `test` 类,并编写 `hello.md` 文件

1. 创建目录

Expand All @@ -69,7 +67,7 @@ VuePress 需要 [Node.js ](https://nodejs.org/en/)>= 8.6
hello world
```

tittle:标题,不填写则默认文件名中的标题,即`hello`
tittle:标题,不填写则默认文件名中的标题,即 `hello`

permalink:访问链接,不填写则自动生成

Expand All @@ -83,35 +81,40 @@ VuePress 需要 [Node.js ](https://nodejs.org/en/)>= 8.6
npm run dev
```

详情请看[vdoing主题介绍文档](https://doc.xugaoyi.com/)
文件及写作规范详情请看

- [vdoing主题介绍文档](https://doc.xugaoyi.com/)
- [文档 - md文件写作](https://oddfar.github.io/notes/about/blog/3/)

## 部署

### 手动部署到github
### 手动部署到 GitHub

创建分支:`gh-pages`

更改文件`deploy.sh`内容

```sh
[email protected]:oddfar/docs.git
```
仓库地址替换成自己的:

- githubUrl=[email protected]:oddfar/notes.git

- githubUrl=https://oddfar:${GITHUB_TOKEN}@github.com/oddfar/notes.git

- initDist "module.exports = '/notes/'"


```sh
githubUrl=https://oddfar:${GITHUB_TOKEN}@github.com/oddfar/docs.git
```

双击运行`deploy.sh`
修好完后,双击运行`deploy.sh`

之后配置 [GitHub Pages](https://pages.github.com/)

![image-20210517151354287](https://cdn.jsdelivr.net/gh/oddfar/static/img/20210517151356.png)

### 自动部署到github
### 自动部署到 GitHub



详情查看:[点击此处](https://github.com/oddfar/notes/blob/master/docs/10.%E5%85%B3%E4%BA%8E/02.%E5%85%B3%E4%BA%8E%20-%20%E6%9C%AC%E7%AB%99/05.%E6%96%87%E6%A1%A3%E7%9A%84%E9%83%A8%E7%BD%B2.md)
详情查看:[点击此处](https://oddfar.github.io/notes/about/blog/5/)

### 部署到自己服务器

Expand All @@ -121,7 +124,7 @@ githubUrl=https://oddfar:${GITHUB_TOKEN}@github.com/oddfar/docs.git
npm run build
```

生成文件在`docs\.vuepress\dist\`目录下
生成文件在 `docs\.vuepress\dist\` 目录下

打包到服务器即可

Expand Down
80 changes: 78 additions & 2 deletions docs/05.工具部署/10.docker/10.Docker - 镜像和仓库.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ date: 2021-06-04 16:45:01
- [分层理解](#%E5%88%86%E5%B1%82%E7%90%86%E8%A7%A3)
- [提交镜像](#%E6%8F%90%E4%BA%A4%E9%95%9C%E5%83%8F)
- [Docker 仓库](#docker-%E4%BB%93%E5%BA%93)
- [DockerHub](#dockerhub)
- [阿里云镜像服务](#%E9%98%BF%E9%87%8C%E4%BA%91%E9%95%9C%E5%83%8F%E6%9C%8D%E5%8A%A1)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -160,7 +162,9 @@ ROOT docs examples host-manager manager

此时再次访问,则不是404

3、提交我们修改后的镜像为 tomcat02 ,下次则可以直接启动这个
**3、提交修改后的镜像为 tomcat02 **

下次则可以直接启动这个

注意:commit的时候,容器的名字不能有大写,否则报错:`invalid reference format`

Expand Down Expand Up @@ -192,4 +196,76 @@ a8b6aff64fa3

## Docker 仓库

待补充
### DockerHub

注册dockerhub https://hub.docker.com/signup

1、登录

```sh
docker login -u oddfar
```

2、将镜像发布出去

```sh
[root@VM-0-6-centos logs]# docker push hello-world
Using default tag: latest
The push refers to repository [docker.io/library/hello-world]
f22b99068db9: Layer already exists
errors:
denied: requested access to the resource is denied
unauthorized: authentication required
```

错误:请求的资源访问被拒绝

问题:本地镜像名无帐号信息,解决加 tag 即可

```sh
[root@VM-0-6-centos logs]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d1165f221234 3 months ago 13.3kB
[root@VM-0-6-centos logs]# docker tag d1165f221234 oddfar/hello-world:1.0
```

oddfar 是我的用户名

3、再次push

```sh
[root@VM-0-6-centos logs]# docker push oddfar/hello-world:1.0
```

访问:https://hub.docker.com/ 可看到提交的镜像

![image-20210606181526206](https://cdn.jsdelivr.net/gh/oddfar/static/img/Docker.assets/10.Docker-镜像和仓库.assets/image-20210606181526206.png)



### 阿里云镜像服务

登录阿里云 -> 找到容器镜像服务 -> 创建命名空间 -> 创建镜像仓库

点击进入这个镜像仓库,可以看到所有的信息

![image-20210606192542790](https://cdn.jsdelivr.net/gh/oddfar/static/img/Docker.assets/10.Docker-镜像和仓库.assets/image-20210606192542790.png)

指令:

![image-20210606204609437](https://cdn.jsdelivr.net/gh/oddfar/static/img/Docker.assets/10.Docker-镜像和仓库.assets/image-20210606204609437.png)

测试:推送 hello-world

```sh
[root@VM-0-6-centos ~]# docker login --username=a_zhiyuan registry.cn-hangzhou.aliyuncs.com
[root@VM-0-6-centos ~]# docker tag d1165f221234 registry.cn-hangzhou.aliyuncs.com/zhiyuan/study:1.0
[root@VM-0-6-centos ~]# docker push registry.cn-hangzhou.aliyuncs.com/zhiyuan/study:1.0
```



提交成功

![image-20210606204641884](https://cdn.jsdelivr.net/gh/oddfar/static/img/Docker.assets/10.Docker-镜像和仓库.assets/image-20210606204641884.png)

Loading

0 comments on commit 0e24188

Please sign in to comment.