docker_practice/cases/ci/travis/README.md

48 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 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/) 查看构建详情。