Overview

https://dagger.io/: Dagger 是 Docker 创始人的 Devops 平台创业项目,A轮融资 2000w 美元。据说这一次会吸取 Docker 的教训,不要被迅速的成功蒙蔽了视野。

Getting Started

https://docs.dagger.io/ 照着官网的文档体验一下。

安装

尝试了下官网的 windows 的安装指导,curl 不支持 Powershell 6|7 的感觉

  1. curl https://dl.dagger.io/dagger/install.ps1 -OutFile install.ps1
  2. ./install.ps1
  3. rm install.ps1

所以选择了通过 scoop 安装

  1. scoop install dagger

测试

首先需要 docker 环境,windows 就是要 docker desktop 啦。

官网测试步骤

  1. git clone https://github.com/dagger/dagger
  2. cd dagger
  3. git checkout v0.2.4
  4. cd pkg/universe.dagger.io/examples/todoapp
  5. dagger do build

我实际执行的时候遇到了错误,不愧是 Devops 的工具,根据运行提示执行就能继续:

  1. D:\temp
  2. dagger version
  3. dagger 0.2.4 (b32c8732) windows/amd64
  4. D:\temp
  5. git clone https://github.com/dagger/dagger
  6. Cloning into 'dagger'...
  7. remote: Enumerating objects: 22883, done.
  8. remote: Counting objects: 100% (648/648), done.
  9. remote: Compressing objects: 100% (161/161), done.
  10. remote: Total 22883 (delta 573), reused 487 (delta 487), pack-reused 22235R
  11. Receiving objects: 100% (22883/22883), 10.32 MiB | 529.00 KiB/s, done.
  12. Resolving deltas: 100% (12441/12441), done.
  13. universe.dagger.io\examples\todoapp on HEAD (b32c873) via
  14. dagger do build
  15. 4:36PM FTL failed to load plan: import failed: cannot find package "dagger.io/dagger":
  16. D:\temp\dagger\pkg\universe.dagger.io\examples\todoapp\todoapp.cue:4:2
  17. : running `dagger project update` may resolve this
  18. universe.dagger.io\examples\todoapp on HEAD (b32c873) via took 2m14s
  19. ls
  20. Directory: D:\temp\dagger\pkg\universe.dagger.io\examples\todoapp
  21. Mode LastWriteTime Length Name
  22. ---- ------------- ------ ----
  23. d---- 2022/3/31 16:32 public
  24. d---- 2022/3/31 16:32 src
  25. -a--- 2022/3/31 16:32 7 .gitignore
  26. -a--- 2022/3/31 16:32 946 package.json
  27. -a--- 2022/3/31 16:32 68 README.md
  28. -a--- 2022/3/31 16:32 1926 todoapp.cue
  29. -a--- 2022/3/31 16:32 467872 yarn.lock
  30. universe.dagger.io\examples\todoapp on HEAD (b32c873) via
  31. dagger project update
  32. universe.dagger.io\examples\todoapp on HEAD (b32c873) via took 4s
  33. dagger do build
  34. [✔] actions.build.run.script 0.3s
  35. [✔] client.filesystem."./".read 0.6s
  36. [✔] actions.test.script 0.4s
  37. [+] actions.deps 347.8s
  38. #8 57.14 (4/4) Installing bash (5.1.16-r0)
  39. #8 70.63 Executing bash-5.1.16-r0.post-install
  40. #8 70.65 Executing busybox-1.34.1-r3.trigger
  41. #8 70.65 OK: 8 MiB in 18 packages
  42. #9 0.346 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
  43. #9 1.872 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
  44. #9 4.026 (1/8) Installing ca-certificates (20211220-r0)
  45. #9 4.294 (2/8) Installing nghttp2-libs (1.46.0-r0)
  46. #9 4.498 (3/8) Installing brotli-libs (1.0.9-r5)
  47. #9 4.960 (4/8) Installing c-ares (1.18.1-r0)
  48. #9 5.124 (5/8) Installing libgcc (10.3.1_git20211027-r0)
  49. #9 5.268 (6/8) Installing libstdc++ (10.3.1_git20211027-r0)
  50. #9 5.953 (7/8) Installing nodejs (16.14.2-r0)
  51. #9 21.82 (8/8) Installing yarn (1.22.17-r0)
  52. #9 23.56 Executing busybox-1.34.1-r3.trigger
  53. #9 23.56 Executing ca-certificates-20211220-r0.trigger
  54. #9 23.62 OK: 55 MiB in 26 packages
  55. #10 0.326 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
  56. #10 8.557 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
  57. #10 58.22 (1/4) Installing libcurl (7.80.0-r0)
  58. #10 62.77 (2/4) Installing expat (2.4.7-r0)
  59. #10 64.41 (3/4) Installing pcre2 (10.39-r0)
  60. #10 70.08 (4/4) Installing git (2.34.1-r0)
  61. #10 202.5 Executing busybox-1.34.1-r3.trigger
  62. #10 202.6 OK: 67 MiB in 30 packages
  63. #12 0.999 yarn config v1.22.17
  64. #12 1.052 success Set "cache-folder" to "/cache/yarn".
  65. #12 1.052 Done in 0.07s.
  66. #12 1.357 yarn install v1.22.17
  67. #12 1.523 [1/4] Resolving packages...
  68. #12 2.454 [2/4] Fetching packages...

很爽,流畅的过去了,可能是试验机器的网络环境好的原因。

  1. universe.dagger.io\examples\todoapp on HEAD (b32c873) via took 4s
  2. dagger do build
  3. [✔] actions.build.run.script 0.3s
  4. [✔] client.filesystem."./".read 0.6s
  5. [✔] actions.test.script 0.4s
  6. [✔] actions.deps 440.0s
  7. [✔] actions.test 1.5s
  8. [✔] actions.build.run 13.0s
  9. [✔] actions.build.contents 0.2s
  10. [✔] client.filesystem."./_build".write 0.7s

测试

因为编译出来的是静态页面,可以直接打开测试,windows 使用 start 即可在浏览器中看到如下页面

  1. start _build/index.html

image.png

第一次修改测试

  1. universe.dagger.io\examples\todoapp on HEAD (b32c873) via
  2. code src

image.png
变更一点信息重新调用 dagger do build。这一次速度当然会很快啦。

  1. universe.dagger.io\examples\todoapp on HEAD (b32c873) via took 5s
  2. dagger do build
  3. [✔] actions.deps 9.9s
  4. [✔] client.filesystem."./".read 0.4s
  5. [✔] actions.build.run.script 0.0s
  6. [✔] actions.test.script 0.0s
  7. [✔] actions.test 3.1s
  8. [✔] actions.build.run 7.0s
  9. [✔] actions.build.contents 0.1s
  10. [✔] client.filesystem."./_build".write 0.2s
  1. start _build/index.html

结果当然不出所料啦

image.png

总结

当然,Local Dev 环境之外,还可以集成自己的 CI 环境啦。示例如图:
image.png
想到最近的 devstream 开源,终于到 devops 领域开花结果了。CUE 语言也是遍地开花了。