Skip to content

Commit

Permalink
Merge pull request lint-md#46 from wi1dcard/fix-docker-image
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc authored Aug 10, 2019
2 parents e6d108b + 55c72de commit d416ed0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
7 changes: 0 additions & 7 deletions packages/lint-md-cli/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
node_modules
lib

Dockerfile
logo.png

**/.DS_STORE
**/.git*

coverage
__tests__
tests
4 changes: 2 additions & 2 deletions packages/lint-md-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /usr/local/lint-md
COPY . .

RUN set -x \
&& yarn install \
&& yarn install --production \
&& ln -s ./bin/index.js /usr/local/bin/lint-md

CMD ["lint-md"]
ENTRYPOINT ["lint-md"]
18 changes: 12 additions & 6 deletions packages/lint-md-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,23 @@ script: lint-md README.md

## 基于 Docker

本地使用 Docker 镜像
假设当前目录有一文件名为 `README.md`,可在本地使用以下命令

```bash
docker run --rm -it yuque/lint-md lint-md README.md Document.md # 也可直接带其它参数
docker run --rm -it -v$(pwd)/docs yuque/lint-md:cli /docs/README.md # 也可直接带其它参数
```

另外,在基于 Docker 的 CI/CD 平台上,可使用 `yuque/lint-md` 镜像。例如 GitLab CI/CD:
其中:

- `--rm` 表示在运行完毕后直接销毁容器。
- `-it` 表示交互式 TTY,你可以理解为进入容器终端。
- `-v$(pwd)/docs` 表示将当前目录「挂载」至容器内部的 `/docs` 目录。

另外,在基于 Docker 的 CI/CD 平台上,也可使用 `yuque/lint-md` 镜像。例如 GitLab CI/CD:

```yml
lint:
image: yuque/lint-md
image: yuque/lint-md:cli
script:
- lint-md README.md # 或其它文件
```
Expand All @@ -127,13 +133,13 @@ version: 2
jobs:
lint:
docker:
- image: yuque/lint-md
- image: yuque/lint-md:cli
steps:
- checkout
- run: lint-md README.md # 或其它文件
```

利用 Docker 作为 CI 的基础环境通常更有优势,不必每次构建都执行 `npm install`;资源节省,速度也会更快些。
利用 Docker 作为 CI 的基础环境通常更有优势,不必每次构建都执行 `yarn install`;资源节省,速度也会更快些。



Expand Down

0 comments on commit d416ed0

Please sign in to comment.