diff --git a/README.md b/README.md index 2d2818f7..7852cd8e 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,23 @@ Quick Reference === -为开发人员分享快速参考备忘单(主要是方便自己),在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。 +为开发人员分享快速参考备忘清单(主要是方便自己),在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。 如果您发现此处的备忘单不合适,您可以通过提交 PR 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。 ## 编程 -[TOML](./docs/toml.md) -[TypeScript](./docs/typescript.md) +[Docker](./docs/docker.md) +[Dockerfile](./docs/dockerfile.md) [JavaScript](./docs/javascript.md) [JSON](./docs/json.md) +[TOML](./docs/toml.md) [Markdown](./docs/markdown.md) +[TypeScript](./docs/typescript.md) ## 工具包 -[Docker](./docs/docker.md) [npm](./docs/npm.md) [package.json](./docs/package.json.md) [Semver](./docs/semver.md) diff --git a/docs/docker.md b/docs/docker.md index 32d0d349..c316b6f0 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -128,7 +128,7 @@ docker rm nginx-server docker update --cpu-shares 512 -m 300M nginx-server ``` -Docker Images +Docker 镜像 ---- @@ -158,7 +158,7 @@ $ docker build -f myOtherDockerfile . $ curl example.com/remote/Dockerfile | docker build -f - . ``` -Docker 联网 +Docker 网络 ---- diff --git a/docs/dockerfile.md b/docs/dockerfile.md new file mode 100644 index 00000000..653aba67 --- /dev/null +++ b/docs/dockerfile.md @@ -0,0 +1,155 @@ +Dockerfile 备忘清单 +=== + +这是 [Dockerfile](https://docs.docker.com/engine/reference/builder/) 的快速参考备忘单。包含用户可以在命令行上调用以组装镜像的所有命令。 + +参考 +---- + +### 继承 + +默认 `Dockerfile` 位于上下文的根目录中。 + +- [Docker 备忘清单](./docker.md) _(github.io)_ + +```shell +docker build -f /path/to/a/Dockerfile . +``` + +使用 `-f` 指向文件系统中任何位置的 `Dockerfile`。 + +### 继承 + +```dockerfile +FROM [--platform=] [AS ] +``` + + +示例 + +```dockerfile +FROM ruby:2.2.2 +FROM golang:1.19-alpine3.16 AS build-env +``` + +### 变量 + +```dockerfile +ENV = ... +``` + +```dockerfile +ENV APP_HOME /myapp +RUN mkdir $APP_HOME +``` + +```dockerfile +ENV MY_NAME="John Doe" MY_DOG=Rex\ The\ Dog \ + MY_CAT=fluffy +``` + +### 初始化 + + +```dockerfile +RUN bundle install +``` + +```dockerfile +WORKDIR /myapp +``` + +```dockerfile +VOLUME ["/data"] +# 安装点规范 +``` + +```dockerfile +ADD file.xyz /file.xyz +COPY --chown=user:group host_file.xyz /path/container_file.xyz +``` + + +### Onbuild + +```dockerfile +ONBUILD RUN bundle install +# 与另一个文件一起使用时 +``` + +### 命令 + +```dockerfile +EXPOSE 5900 +CMD ["bundle", "exec", "rails", "server"] +``` + +### 在严格的 shell 中运行命令 + +```dockerfile +ENV my_var +SHELL ["/bin/bash", "-euo", "pipefail", "-c"] +# With strict mode: +RUN false # ails 像使用 && 一样构建 +RUN echo "$myvar" # 由于拼写错误会抛出错误 +RUN true | false # 将脱离管道 +``` + + +使用 `shell` 将为 shell 命令打开严格模式。 + +### 入口点 + +```dockerfile +ENTRYPOINT ["executable", "param1", "param2"] +ENTRYPOINT command param1 param2 +``` + + +配置将作为可执行文件运行的容器。 + +```dockerfile +ENTRYPOINT exec top -b +``` + +这将使用 shell 处理来替换 shell 变量,并将忽略任何 `CMD` 或 `docker run` 命令行参数。 + +### 元数据 + +```dockerfile +LABEL version="1.0" +``` + +```dockerfile +LABEL "com.example.vendor"="ACME Incorporated" +LABEL com.example.label-with-value="foo" +LABEL version="1.0" +``` + + +```dockerfile +LABEL description="本文说明\ +标签值可以跨越多行。" +LABEL multi.label1="value1" \ + multi.label2="value2" \ + other="value3" +``` + +### 主要命令 + + +命令 | 说明 +:- | - +`FROM image` | 构建的基础镜像 +~~`MAINTAINER email`~~ | (已弃用)维护者的名字 +`COPY [--chown=:] ... ` | 将上下文中的路径复制到位置 `dest` 的容器中 +`ADD [--chown=:] ... ` | 与 `COPY` 相同,但解压缩存档并接受 http url。 +`RUN ` | 在容器内运行任意命令。 +`USER [:]` | 设置默认用户名。 +`WORKDIR /path/to/workdir` | 设置默认工作目录。 +`CMD command param1 param2` | 设置默认命令 +`ENV = ...` | 设置环境变量 +`EXPOSE [/...]` | 运行时侦听指定的网络端口 + +## 也可以看看 +- [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) _(docker.com)_ \ No newline at end of file diff --git a/docs/quickreference.md b/docs/quickreference.md index 558e30ae..b9451528 100644 --- a/docs/quickreference.md +++ b/docs/quickreference.md @@ -128,7 +128,7 @@ function () {} [鼠标移动到上面有提示](https://github.com/jaywcjlove/reference) _Tooltips 的提示内容_ -添加注释配置 `` 添加一个 tooltips 提示。 +添加注释配置 `` 添加一个 Tooltips 提示。 ### H3 部分(卡片)背景颜色 diff --git a/scripts/assets/dockerfile.svg b/scripts/assets/dockerfile.svg new file mode 100644 index 00000000..51f22125 --- /dev/null +++ b/scripts/assets/dockerfile.svg @@ -0,0 +1,3 @@ + + + diff --git a/scripts/assets/emoji.svg b/scripts/assets/emoji.svg index 26a46993..08ef8314 100644 --- a/scripts/assets/emoji.svg +++ b/scripts/assets/emoji.svg @@ -1,3 +1,3 @@ - + diff --git a/scripts/assets/sed.svg b/scripts/assets/sed.svg new file mode 100644 index 00000000..eeb557a1 --- /dev/null +++ b/scripts/assets/sed.svg @@ -0,0 +1,3 @@ + + + diff --git a/scripts/nodes/header.mjs b/scripts/nodes/header.mjs index b3fe05aa..6d0e5a15 100644 --- a/scripts/nodes/header.mjs +++ b/scripts/nodes/header.mjs @@ -1,6 +1,10 @@ -import { logo, github, editor } from './logo.mjs'; +import path from 'path'; +import { github, editor } from './logo.mjs'; +import { getSVGNode } from '../utils/getSVGNode.mjs'; +const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg') export function header({ homePath, githubURL = '' }) { + const svgNode = getSVGNode(ICONS_PATH) const data = [ { href: githubURL, @@ -35,7 +39,19 @@ export function header({ homePath, githubURL = '' }) { href: homePath, class: ['logo'], }, - children: logo, + children: [ + ...svgNode, + { + type: 'element', + tagName: 'span', + properties: { + class: ['title'], + }, + children: [ + { type: 'text', value: 'Quick Reference' } + ] + } + ], }, { type: 'element', diff --git a/scripts/style.css b/scripts/style.css index 616ee04c..0950802d 100644 --- a/scripts/style.css +++ b/scripts/style.css @@ -43,7 +43,7 @@ table { border-collapse: collapse } -table td:not(:last-child)>code, ul li > code, kbd { +table td:not(:last-child)>code, table td:not(:last-child)>del>code, ul li > code, kbd { background-color: rgb(51 65 85/0.5); color: rgb(203 213 225/1); box-shadow: 0 0 #0000, 0 0 #0000, 0 0 #0000; @@ -84,6 +84,11 @@ table td:first-child>code { --text-opacity: 1; color: rgb(5 150 105/var(--text-opacity)); } +table td:first-child>del>code { + text-decoration: inherit; + --text-opacity: 1; + color: rgb(244 67 54/var(--text-opacity)); +} table.show-header thead { display: table-header-group; @@ -188,7 +193,7 @@ body.home .h1wrap p { --bg-opacity: 1; } .home-card a svg { - min-width: 1.5rem; + min-width: 1.6rem; height: 1.8rem; } @@ -703,7 +708,6 @@ a.text-grey { /* 代码高亮 End */ - .footer-wrap { margin-top: 3.5rem; color: rgb(100 116 139/1); diff --git a/scripts/utils/getSVGNode.mjs b/scripts/utils/getSVGNode.mjs new file mode 100644 index 00000000..f3206c26 --- /dev/null +++ b/scripts/utils/getSVGNode.mjs @@ -0,0 +1,13 @@ +import fs from 'fs-extra'; +import rehypeParse from 'rehype-parse'; +import {unified} from 'unified'; +import { VFile } from 'vfile'; + +export function getSVGNode(iconPath) { + const svgStr = fs.readFileSync(iconPath); + const processor = unified().use(rehypeParse,{ fragment: true, space: "svg" }) + const file = new VFile(); + file.value = svgStr.toString(); + const hastNode = processor.runSync(processor.parse(file), file); + return hastNode.children || [] +} \ No newline at end of file diff --git a/scripts/utils/homeCardIcons.mjs b/scripts/utils/homeCardIcons.mjs index 1cb2a73b..2afb3784 100644 --- a/scripts/utils/homeCardIcons.mjs +++ b/scripts/utils/homeCardIcons.mjs @@ -1,20 +1,9 @@ import fs from 'fs-extra'; -import rehypeParse from 'rehype-parse' -import {unified} from 'unified' import path from 'path'; -import { VFile } from 'vfile'; +import { getSVGNode } from './getSVGNode.mjs'; const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets') -function getSVGNode(iconPath) { - const svgStr = fs.readFileSync(iconPath); - const processor = unified().use(rehypeParse,{ fragment: true, space: "svg" }) - const file = new VFile(); - file.value = svgStr.toString(); - const hastNode = processor.runSync(processor.parse(file), file); - return hastNode.children || [] -} - export function homeCardIcons(node, parent, isHome) { if (isHome && node && node.type === 'element' && node.properties?.class?.includes('home-card')) { node.children = node.children.map((child) => {