parent
2cd0fac44b
commit
aa3d56fce9
|
@ -51,7 +51,6 @@ jobs:
|
||||||
"security.ubuntu.com/ubuntu",\
|
"security.ubuntu.com/ubuntu",\
|
||||||
"nginx.com",\
|
"nginx.com",\
|
||||||
"img.shields.io/github/release/yeasy/docker_practice",\
|
"img.shields.io/github/release/yeasy/docker_practice",\
|
||||||
"travis-ci.org/yeasy/docker_practice.svg",\
|
|
||||||
"launchpad.net",\
|
"launchpad.net",\
|
||||||
"www.w3.org/1999",\
|
"www.w3.org/1999",\
|
||||||
"chat.freenode.net",\
|
"chat.freenode.net",\
|
||||||
|
|
|
@ -99,7 +99,7 @@ jobs:
|
||||||
PCIT_GIT_URL: github.com/docker-practice/vuepress
|
PCIT_GIT_URL: github.com/docker-practice/vuepress
|
||||||
PCIT_KEEP_HISTORY: "true"
|
PCIT_KEEP_HISTORY: "true"
|
||||||
PCIT_LOCAL_DIR: .vuepress/dist
|
PCIT_LOCAL_DIR: .vuepress/dist
|
||||||
PCIT_MESSAGE: Sync from yeasy/docker_practice@${{github.sha}} by PCIT
|
PCIT_MESSAGE: Build from yeasy/docker_practice@${{github.sha}}
|
||||||
PCIT_TARGET_BRANCH: master
|
PCIT_TARGET_BRANCH: master
|
||||||
PCIT_USERNAME: khs1994
|
PCIT_USERNAME: khs1994
|
||||||
- name: Set coding.net CNAME
|
- name: Set coding.net CNAME
|
||||||
|
|
|
@ -222,7 +222,6 @@ module.exports = config({
|
||||||
'drone/install'
|
'drone/install'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'travis/'
|
|
||||||
],
|
],
|
||||||
'/': [
|
'/': [
|
||||||
'/',
|
'/',
|
||||||
|
|
|
@ -146,7 +146,6 @@
|
||||||
* [GitHub Actions](cases/ci/actions/README.md)
|
* [GitHub Actions](cases/ci/actions/README.md)
|
||||||
* [Drone](cases/ci/drone/README.md)
|
* [Drone](cases/ci/drone/README.md)
|
||||||
* [部署 Drone](cases/ci/drone/install.md)
|
* [部署 Drone](cases/ci/drone/install.md)
|
||||||
* [Travis CI](cases/ci/travis/README.md)
|
|
||||||
* [在 IDE 中使用 Docker](ide/README.md)
|
* [在 IDE 中使用 Docker](ide/README.md)
|
||||||
* [VS Code](ide/vsCode.md)
|
* [VS Code](ide/vsCode.md)
|
||||||
* [podman - 下一代 Linux 容器工具](podman/README.md)
|
* [podman - 下一代 Linux 容器工具](podman/README.md)
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
# 在 Travis CI 中使用 Docker
|
|
||||||
|
|
||||||
当代码提交到 GitHub 时,[Travis CI](https://travis-ci.com/) 会根据项目根目录 `.travis.yml` 文件设置的指令,执行一系列操作。
|
|
||||||
|
|
||||||
本小节介绍如何在 Travis CI 中使用 Docker 进行持续集成/持续部署(CI/CD)。这里以当代码提交到 GitHub 时自动构建 Docker 镜像并推送到 Docker Hub 为例进行介绍。
|
|
||||||
|
|
||||||
## 准备
|
|
||||||
|
|
||||||
首先登录 https://travis-ci.com/account/repositories 选择 GitHub 仓库,按照指引安装 GitHub App 来启用 GitHub 仓库构建。
|
|
||||||
|
|
||||||
在项目根目录新建一个 `Dockerfile` 文件。
|
|
||||||
|
|
||||||
```docker
|
|
||||||
FROM alpine
|
|
||||||
|
|
||||||
RUN echo "Hello World"
|
|
||||||
```
|
|
||||||
|
|
||||||
新建 Travis CI 配置文件 `.travis.yml` 文件。
|
|
||||||
|
|
||||||
```yml
|
|
||||||
language: bash
|
|
||||||
|
|
||||||
dist: xenial
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
# 登录到 docker hub
|
|
||||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
|
||||||
|
|
||||||
script:
|
|
||||||
# 这里编写测试代码的命令
|
|
||||||
- echo "test code"
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
# 当代码测试通过后执行的命令
|
|
||||||
- docker build -t username/alpine .
|
|
||||||
- docker push username/alpine
|
|
||||||
```
|
|
||||||
|
|
||||||
> 请提前在 Travis CI 仓库设置页面配置 `DOCKER_PASSWORD` `DOCKER_USERNAME` 变量
|
|
||||||
|
|
||||||
## 查看结果
|
|
||||||
|
|
||||||
将项目推送到 GitHub,登录 [Travis CI](https://travis-ci.com/) 查看构建详情。
|
|
|
@ -1,16 +0,0 @@
|
||||||
language: bash
|
|
||||||
|
|
||||||
dist: xenial
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
|
||||||
|
|
||||||
script:
|
|
||||||
- echo "test code"
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- docker build -t username/alpine .
|
|
||||||
- docker push username/alpine
|
|
|
@ -1,3 +0,0 @@
|
||||||
FROM alpine
|
|
||||||
|
|
||||||
RUN echo "Hello World"
|
|
Loading…
Reference in New Issue