惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
量子位
博客园 - 司徒正美
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Palo Alto Networks Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
小众软件
小众软件
T
Threatpost
Latest news
Latest news
J
Java Code Geeks
博客园 - Franky
博客园 - 三生石上(FineUI控件)
Project Zero
Project Zero
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
Simon Willison's Weblog
Simon Willison's Weblog
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
人人都是产品经理
人人都是产品经理
S
Schneier on Security
T
The Blog of Author Tim Ferriss
V
V2EX
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
罗磊的独立博客
IT之家
IT之家
雷峰网
雷峰网
H
Help Net Security
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
C
Cybersecurity and Infrastructure Security Agency CISA
I
InfoQ
GbyAI
GbyAI
博客园 - 叶小钗
PCI Perspectives
PCI Perspectives
The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
H
Heimdal Security Blog
Spread Privacy
Spread Privacy
博客园_首页
A
About on SuperTechFans
T
Tailwind CSS Blog
The Register - Security
The Register - Security

Docker 从入门到实践

修订记录 如何贡献 Docker — 从入门到实践 高级网络配置 容器访问控制 自定义网桥 编辑网络配置文件 配置 docker0 网桥 工具和示例 映射容器端口到宿主主机的实现 示例:创建一个点到点连接 快速配置指南 附录 Dockerfile 最佳实践 Docker 命令查询 客户端命令(docker) 服务端命令(dockerd) 如何调试 Docker 常见问题总结 热门镜像介绍 Node.js 资源链接 归档项目 基本概念 Docker 容器 Docker 镜像 Docker Buildx 使用 BuildKit 构建镜像 使用 Buildx 构建镜像 使用 buildx 构建多种系统架构支持的 Docker 镜像 CI/CD GitHub Actions Drone Demo 部署 Drone Alpine Busybox CentOS/Fedora Debian/Ubuntu 容器与云计算 亚马逊云 腾讯云 Docker Compose 项目 Compose 命令说明 Compose 模板文件 使用 Django 安装与卸载 Compose 简介 使用 compose 搭建 LNMP 环境 使用 Rails 使用 使用 WordPress 操作 Docker 容器 进入容器 后台运行 导出和导入容器 删除容器 启动容器 终止容器 Fedora CoreOS 安装 Fedora CoreOS Fedora CoreOS 介绍 Docker 数据管理 挂载主机目录 数据卷 etcd 集群 使用 etcdctl 使用 etcdctl v2 什么是 etcd 在 IDE 中使用 Docker VS Code 中使用 Docker 使用 Dockerfile 定制镜像 使用 Docker 镜像 利用 commit 理解镜像构成 Dockerfile 指令详解 ADD 更高级的复制文件 ARG 构建参数 CMD 容器启动命令 COPY 复制文件 ENTRYPOINT 入口点 EXPOSE 声明端口 CentOS minio MongoDB MySQL Nginx PHP Redis Ubuntu WordPress Docker Registry 操作系统 本章小结 阿里云 简介 本章小结 etcd 安装 Docker — 从入门到实践
Drone
2022-05-13 · via Docker 从入门到实践

# Drone

基于 DockerCI/CD 工具 Drone 所有编译、测试的流程都在 Docker 容器中进行。

开发者只需在项目中包含 .drone.yml 文件,将代码推送到 git 仓库,Drone 就能够自动化的进行编译、测试、发布。

本小节以 GitHub + Drone 来演示 Drone 的工作流程。当然在实际开发过程中,你的代码也许不在 GitHub 托管,那么你可以尝试使用 Gogs + Drone 来进行 CI/CD

# Drone 关联项目

在 Github 新建一个名为 drone-demo 的仓库。

打开我们已经 部署好的 Drone 网站 或者 Drone Cloud (opens new window),使用 GitHub 账号登录,在界面中关联刚刚新建的 drone-demo 仓库。

# 编写项目源代码

初始化一个 git 仓库

$ mkdir drone-demo

$ cd drone-demo

$ git init

$ git remote add origin git@github.com:username/drone-demo.git

1
2
3
4
5
6
7

这里以一个简单的 Go 程序为例,该程序输出 Hello World!

编写 app.go 文件

package main

import "fmt"

func main(){
    fmt.Printf("Hello World!\n");
}

1
2
3
4
5
6
7

编写 .drone.yml 文件

kind: pipeline
type: docker
name: build
steps:
- name: build
  image: golang:alpine
  pull: if-not-exists # always never
  environment:
    KEY: VALUE
  commands:
    - echo $KEY
    - pwd
    - ls
    - CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
    - ./app

trigger:
  branch:
  - master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

现在目录结构如下

.
├── .drone.yml
└── app.go

1
2
3

# 推送项目源代码到 GitHub

$ git add .

$ git commit -m "test drone ci"

$ git push origin master

1
2
3
4
5

# 查看项目构建过程及结果

打开我们部署好的 Drone 网站或者 Drone Cloud,即可看到构建结果。

当然我们也可以把构建结果上传到 GitHub,Docker Registry,云服务商提供的对象存储,或者生产环境中。

本书 GitBook 也使用 Drone 进行 CI/CD,具体配置信息请查看本书根目录 .drone.yml (opens new window) 文件。

# 参考链接