前言
Gitea 和 Drone 的安装部署请阅读以下文章,本文简单分享三种常用的 drone 工作流 CI 配置.
本文为 Stille 原创文章.经实践,测试,整理发布.如需转载请联系作者获得授权,并注明转载地址.
docker 镜像的构建和上传
默认是在仓库根目录进行构建,并将你的 docker hub 账号密码配置在 drone – Settings 里.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<pre class="inline:true decode:1 " >kind: pipeline name: docker build steps: - name: docker image: plugins/docker settings: username: from_secret: docker_username password: from_secret: docker_password repo: stilleshan/frpc tags: - latest |
如果需要构建的项目文件及 Dockerfile在子目录,则需要配置 context和 dockerfile参数,例如以下构建 frpc的镜像则是在子目录里.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<pre class="inline:true decode:1 " >kind: pipeline name: docker build steps: - name: docker image: plugins/docker settings: username: from_secret: docker_username password: from_secret: docker_password repo: ioiox/frpc context: frpc dockerfile: frpc/Dockerfile tags: - latest |
使用特定的功能镜像
可以使用一些工具型镜像来完成一些后续操作,例如 stilleshan/coscmd是用于上传文件到腾讯云 COS 对象存储,可以预先在仓库里配置 .cos.conf相关 API key 等信息,不过注意建议在私有仓库来这么做,以免泄露 COS 相关信息.
1 2 3 4 5 6 7 8 9 |
<pre class="inline:true decode:1 " >kind: pipeline name: cos steps: - name: cos image: stilleshan/coscmd commands: - mv .cos.conf /root/.cos.conf - coscmd upload -rfs frpc /frpc |
常规 shell 操作
如果不想安装官方 EXEC 的 runner 来执行 shell, 也可是可以直接使用容器来执行,可以预先搭建好容器环境,也可以使用官方镜像直接在工作流里安装环境,在执行后续操作.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<pre class="inline:true decode:1 " >kind: pipeline name: test shell steps: - name: testing image: alpine commands: - echo hello world - pwd - ls - ls -la - date - apk add ... |
本站提供免费和付费的技术支持.你可以通过留言,邮件,TG群的方式来技术交流和免费咨询.同时也可以付费支持的方式获得相关的技术支持,项目部署配置等服务.具体相关详情请点击查看 技术支持页面
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END