@lakutata/docker 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +309 -0
  3. package/THIRD_PARTY_NOTICES.md +299 -0
  4. package/dist/cjs/client/BuildContext.d.ts +22 -0
  5. package/dist/cjs/client/BuildContext.js +76 -0
  6. package/dist/cjs/client/BuildKitProgress.d.ts +81 -0
  7. package/dist/cjs/client/BuildKitProgress.js +195 -0
  8. package/dist/cjs/client/DockerClient.d.ts +196 -0
  9. package/dist/cjs/client/DockerClient.js +312 -0
  10. package/dist/cjs/client/DockerConnection.d.ts +154 -0
  11. package/dist/cjs/client/DockerConnection.js +397 -0
  12. package/dist/cjs/client/DockerIgnore.d.ts +44 -0
  13. package/dist/cjs/client/DockerIgnore.js +186 -0
  14. package/dist/cjs/client/DockerRequestError.d.ts +17 -0
  15. package/dist/cjs/client/DockerRequestError.js +24 -0
  16. package/dist/cjs/client/DockerStreams.d.ts +35 -0
  17. package/dist/cjs/client/DockerStreams.js +117 -0
  18. package/dist/cjs/client/types/ContainerCreateResponse.d.ts +7 -0
  19. package/dist/cjs/client/types/ContainerCreateResponse.js +2 -0
  20. package/dist/cjs/client/types/ContainerStopQuery.d.ts +13 -0
  21. package/dist/cjs/client/types/ContainerStopQuery.js +2 -0
  22. package/dist/cjs/client/types/DeviceMapping.d.ts +8 -0
  23. package/dist/cjs/client/types/DeviceMapping.js +2 -0
  24. package/dist/cjs/client/types/IdResponse.d.ts +6 -0
  25. package/dist/cjs/client/types/IdResponse.js +2 -0
  26. package/dist/cjs/client/types/NetworkCreateResponse.d.ts +7 -0
  27. package/dist/cjs/client/types/NetworkCreateResponse.js +2 -0
  28. package/dist/cjs/client/types/PortBinding.d.ts +10 -0
  29. package/dist/cjs/client/types/PortBinding.js +2 -0
  30. package/dist/cjs/docker/ConnectionOptionsBuilder.d.ts +128 -0
  31. package/dist/cjs/docker/ConnectionOptionsBuilder.js +150 -0
  32. package/dist/cjs/docker/Docker.d.ts +301 -0
  33. package/dist/cjs/docker/Docker.js +703 -0
  34. package/dist/cjs/docker/exceptions/DockerConnectionException.d.ts +9 -0
  35. package/dist/cjs/docker/exceptions/DockerConnectionException.js +16 -0
  36. package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
  37. package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.js +16 -0
  38. package/dist/cjs/docker/exceptions/DockerImageBuildException.d.ts +9 -0
  39. package/dist/cjs/docker/exceptions/DockerImageBuildException.js +16 -0
  40. package/dist/cjs/docker/exceptions/DockerImageImportException.d.ts +9 -0
  41. package/dist/cjs/docker/exceptions/DockerImageImportException.js +16 -0
  42. package/dist/cjs/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
  43. package/dist/cjs/docker/exceptions/DockerImageNotFoundException.js +17 -0
  44. package/dist/cjs/docker/exceptions/DockerImagePullException.d.ts +9 -0
  45. package/dist/cjs/docker/exceptions/DockerImagePullException.js +16 -0
  46. package/dist/cjs/docker/exceptions/DockerImagePushException.d.ts +8 -0
  47. package/dist/cjs/docker/exceptions/DockerImagePushException.js +15 -0
  48. package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
  49. package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.js +15 -0
  50. package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
  51. package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.js +16 -0
  52. package/dist/cjs/docker/exceptions/DockerRequestException.d.ts +22 -0
  53. package/dist/cjs/docker/exceptions/DockerRequestException.js +24 -0
  54. package/dist/cjs/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
  55. package/dist/cjs/docker/interfaces/IDockerConnectionOptions.js +2 -0
  56. package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
  57. package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.js +2 -0
  58. package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
  59. package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.js +2 -0
  60. package/dist/cjs/docker/interfaces/IDockerKeyObject.d.ts +14 -0
  61. package/dist/cjs/docker/interfaces/IDockerKeyObject.js +2 -0
  62. package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
  63. package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.js +2 -0
  64. package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
  65. package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.js +2 -0
  66. package/dist/cjs/docker/lib/DockerContainer.d.ts +315 -0
  67. package/dist/cjs/docker/lib/DockerContainer.js +742 -0
  68. package/dist/cjs/docker/lib/DockerContainerTTY.d.ts +99 -0
  69. package/dist/cjs/docker/lib/DockerContainerTTY.js +157 -0
  70. package/dist/cjs/docker/lib/DockerImage.d.ts +153 -0
  71. package/dist/cjs/docker/lib/DockerImage.js +273 -0
  72. package/dist/cjs/docker/lib/EngineSettings.d.ts +41 -0
  73. package/dist/cjs/docker/lib/EngineSettings.js +86 -0
  74. package/dist/cjs/docker/lib/ParseBaseImages.d.ts +9 -0
  75. package/dist/cjs/docker/lib/ParseBaseImages.js +50 -0
  76. package/dist/cjs/docker/lib/ParseEnvToRecord.d.ts +14 -0
  77. package/dist/cjs/docker/lib/ParseEnvToRecord.js +25 -0
  78. package/dist/cjs/docker/lib/ParseRepositoryTag.d.ts +17 -0
  79. package/dist/cjs/docker/lib/ParseRepositoryTag.js +48 -0
  80. package/dist/cjs/docker/lib/RegistryAuth.d.ts +8 -0
  81. package/dist/cjs/docker/lib/RegistryAuth.js +15 -0
  82. package/dist/cjs/docker/options/DockerPruneOptions.d.ts +38 -0
  83. package/dist/cjs/docker/options/DockerPruneOptions.js +47 -0
  84. package/dist/cjs/docker/options/auth/DockerAuthOptions.d.ts +46 -0
  85. package/dist/cjs/docker/options/auth/DockerAuthOptions.js +59 -0
  86. package/dist/cjs/docker/options/container/ContainerCommitOptions.d.ts +28 -0
  87. package/dist/cjs/docker/options/container/ContainerCommitOptions.js +39 -0
  88. package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
  89. package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.js +43 -0
  90. package/dist/cjs/docker/options/container/ContainerExecOptions.d.ts +26 -0
  91. package/dist/cjs/docker/options/container/ContainerExecOptions.js +38 -0
  92. package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
  93. package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.js +39 -0
  94. package/dist/cjs/docker/options/container/ContainerKillOptions.d.ts +25 -0
  95. package/dist/cjs/docker/options/container/ContainerKillOptions.js +36 -0
  96. package/dist/cjs/docker/options/container/ContainerLogsOptions.d.ts +48 -0
  97. package/dist/cjs/docker/options/container/ContainerLogsOptions.js +56 -0
  98. package/dist/cjs/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
  99. package/dist/cjs/docker/options/container/ContainerRemoveOptions.js +34 -0
  100. package/dist/cjs/docker/options/container/ContainerSettingOptions.d.ts +137 -0
  101. package/dist/cjs/docker/options/container/ContainerSettingOptions.js +136 -0
  102. package/dist/cjs/docker/options/container/ContainerStopOptions.d.ts +28 -0
  103. package/dist/cjs/docker/options/container/ContainerStopOptions.js +40 -0
  104. package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  105. package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
  106. package/dist/cjs/docker/options/image/ImageBuildOptions.d.ts +117 -0
  107. package/dist/cjs/docker/options/image/ImageBuildOptions.js +111 -0
  108. package/dist/cjs/docker/options/image/ImageExportOptions.d.ts +33 -0
  109. package/dist/cjs/docker/options/image/ImageExportOptions.js +44 -0
  110. package/dist/cjs/docker/options/image/ImageImportOptions.d.ts +28 -0
  111. package/dist/cjs/docker/options/image/ImageImportOptions.js +42 -0
  112. package/dist/cjs/docker/options/image/ImagePullOptions.d.ts +49 -0
  113. package/dist/cjs/docker/options/image/ImagePullOptions.js +63 -0
  114. package/dist/cjs/docker/options/image/ImagePushOptions.d.ts +41 -0
  115. package/dist/cjs/docker/options/image/ImagePushOptions.js +56 -0
  116. package/dist/cjs/docker/options/image/ImageRemoveOptions.d.ts +26 -0
  117. package/dist/cjs/docker/options/image/ImageRemoveOptions.js +38 -0
  118. package/dist/cjs/docker/options/image/ImageTagOptions.d.ts +25 -0
  119. package/dist/cjs/docker/options/image/ImageTagOptions.js +38 -0
  120. package/dist/cjs/docker/options/network/NetworkCreateOptions.d.ts +54 -0
  121. package/dist/cjs/docker/options/network/NetworkCreateOptions.js +63 -0
  122. package/dist/cjs/docker/types/ContainerBind.d.ts +19 -0
  123. package/dist/cjs/docker/types/ContainerBind.js +2 -0
  124. package/dist/cjs/docker/types/ContainerCapability.d.ts +286 -0
  125. package/dist/cjs/docker/types/ContainerCapability.js +290 -0
  126. package/dist/cjs/docker/types/ContainerConfig.d.ts +67 -0
  127. package/dist/cjs/docker/types/ContainerConfig.js +2 -0
  128. package/dist/cjs/docker/types/ContainerDevice.d.ts +19 -0
  129. package/dist/cjs/docker/types/ContainerDevice.js +2 -0
  130. package/dist/cjs/docker/types/ContainerExecResult.d.ts +20 -0
  131. package/dist/cjs/docker/types/ContainerExecResult.js +2 -0
  132. package/dist/cjs/docker/types/ContainerNetwork.d.ts +46 -0
  133. package/dist/cjs/docker/types/ContainerNetwork.js +2 -0
  134. package/dist/cjs/docker/types/ContainerPort.d.ts +25 -0
  135. package/dist/cjs/docker/types/ContainerPort.js +2 -0
  136. package/dist/cjs/docker/types/ContainerRestartPolicy.d.ts +11 -0
  137. package/dist/cjs/docker/types/ContainerRestartPolicy.js +2 -0
  138. package/dist/cjs/docker/types/ContainerState.d.ts +48 -0
  139. package/dist/cjs/docker/types/ContainerState.js +2 -0
  140. package/dist/cjs/docker/types/ContainerStats.d.ts +408 -0
  141. package/dist/cjs/docker/types/ContainerStats.js +2 -0
  142. package/dist/cjs/docker/types/DockerOutputCallback.d.ts +8 -0
  143. package/dist/cjs/docker/types/DockerOutputCallback.js +2 -0
  144. package/dist/cjs/docker/types/ImageConfig.d.ts +34 -0
  145. package/dist/cjs/docker/types/ImageConfig.js +2 -0
  146. package/dist/cjs/docker/types/ImageExposePort.d.ts +17 -0
  147. package/dist/cjs/docker/types/ImageExposePort.js +2 -0
  148. package/dist/cjs/docker/types/NetworkInfo.d.ts +59 -0
  149. package/dist/cjs/docker/types/NetworkInfo.js +2 -0
  150. package/dist/cjs/docker/types/RepositoryTag.d.ts +15 -0
  151. package/dist/cjs/docker/types/RepositoryTag.js +2 -0
  152. package/dist/cjs/exports/Docker.d.ts +73 -0
  153. package/dist/cjs/exports/Docker.js +92 -0
  154. package/dist/cjs/package.json +1 -0
  155. package/dist/esm/client/BuildContext.js +70 -0
  156. package/dist/esm/client/BuildKitProgress.js +190 -0
  157. package/dist/esm/client/DockerClient.js +307 -0
  158. package/dist/esm/client/DockerConnection.js +355 -0
  159. package/dist/esm/client/DockerIgnore.js +179 -0
  160. package/dist/esm/client/DockerRequestError.js +20 -0
  161. package/dist/esm/client/DockerStreams.js +111 -0
  162. package/dist/esm/client/types/ContainerCreateResponse.js +1 -0
  163. package/dist/esm/client/types/ContainerStopQuery.js +1 -0
  164. package/dist/esm/client/types/DeviceMapping.js +1 -0
  165. package/dist/esm/client/types/IdResponse.js +1 -0
  166. package/dist/esm/client/types/NetworkCreateResponse.js +1 -0
  167. package/dist/esm/client/types/PortBinding.js +1 -0
  168. package/dist/esm/docker/ConnectionOptionsBuilder.js +142 -0
  169. package/dist/esm/docker/Docker.js +697 -0
  170. package/dist/esm/docker/exceptions/DockerConnectionException.js +12 -0
  171. package/dist/esm/docker/exceptions/DockerContainerNotFoundException.js +12 -0
  172. package/dist/esm/docker/exceptions/DockerImageBuildException.js +12 -0
  173. package/dist/esm/docker/exceptions/DockerImageImportException.js +12 -0
  174. package/dist/esm/docker/exceptions/DockerImageNotFoundException.js +13 -0
  175. package/dist/esm/docker/exceptions/DockerImagePullException.js +12 -0
  176. package/dist/esm/docker/exceptions/DockerImagePushException.js +11 -0
  177. package/dist/esm/docker/exceptions/DockerImageRepoTagNotFoundException.js +11 -0
  178. package/dist/esm/docker/exceptions/DockerNetworkNotFoundException.js +12 -0
  179. package/dist/esm/docker/exceptions/DockerRequestException.js +20 -0
  180. package/dist/esm/docker/interfaces/IDockerConnectionOptions.js +1 -0
  181. package/dist/esm/docker/interfaces/IDockerHttpConnectionOptions.js +1 -0
  182. package/dist/esm/docker/interfaces/IDockerHttpsConnectionOptions.js +1 -0
  183. package/dist/esm/docker/interfaces/IDockerKeyObject.js +1 -0
  184. package/dist/esm/docker/interfaces/IDockerSSHConnectionOptions.js +1 -0
  185. package/dist/esm/docker/interfaces/IDockerSocketConnectionOptions.js +1 -0
  186. package/dist/esm/docker/lib/DockerContainer.js +739 -0
  187. package/dist/esm/docker/lib/DockerContainerTTY.js +154 -0
  188. package/dist/esm/docker/lib/DockerImage.js +270 -0
  189. package/dist/esm/docker/lib/EngineSettings.js +78 -0
  190. package/dist/esm/docker/lib/ParseBaseImages.js +47 -0
  191. package/dist/esm/docker/lib/ParseEnvToRecord.js +22 -0
  192. package/dist/esm/docker/lib/ParseRepositoryTag.js +45 -0
  193. package/dist/esm/docker/lib/RegistryAuth.js +12 -0
  194. package/dist/esm/docker/options/DockerPruneOptions.js +43 -0
  195. package/dist/esm/docker/options/auth/DockerAuthOptions.js +55 -0
  196. package/dist/esm/docker/options/container/ContainerCommitOptions.js +35 -0
  197. package/dist/esm/docker/options/container/ContainerCreateTTYOptions.js +39 -0
  198. package/dist/esm/docker/options/container/ContainerExecOptions.js +34 -0
  199. package/dist/esm/docker/options/container/ContainerExportDirectoryOptions.js +35 -0
  200. package/dist/esm/docker/options/container/ContainerKillOptions.js +32 -0
  201. package/dist/esm/docker/options/container/ContainerLogsOptions.js +52 -0
  202. package/dist/esm/docker/options/container/ContainerRemoveOptions.js +30 -0
  203. package/dist/esm/docker/options/container/ContainerSettingOptions.js +132 -0
  204. package/dist/esm/docker/options/container/ContainerStopOptions.js +36 -0
  205. package/dist/esm/docker/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
  206. package/dist/esm/docker/options/image/ImageBuildOptions.js +107 -0
  207. package/dist/esm/docker/options/image/ImageExportOptions.js +40 -0
  208. package/dist/esm/docker/options/image/ImageImportOptions.js +38 -0
  209. package/dist/esm/docker/options/image/ImagePullOptions.js +59 -0
  210. package/dist/esm/docker/options/image/ImagePushOptions.js +52 -0
  211. package/dist/esm/docker/options/image/ImageRemoveOptions.js +34 -0
  212. package/dist/esm/docker/options/image/ImageTagOptions.js +34 -0
  213. package/dist/esm/docker/options/network/NetworkCreateOptions.js +59 -0
  214. package/dist/esm/docker/types/ContainerBind.js +1 -0
  215. package/dist/esm/docker/types/ContainerCapability.js +287 -0
  216. package/dist/esm/docker/types/ContainerConfig.js +1 -0
  217. package/dist/esm/docker/types/ContainerDevice.js +1 -0
  218. package/dist/esm/docker/types/ContainerExecResult.js +1 -0
  219. package/dist/esm/docker/types/ContainerNetwork.js +1 -0
  220. package/dist/esm/docker/types/ContainerPort.js +1 -0
  221. package/dist/esm/docker/types/ContainerRestartPolicy.js +1 -0
  222. package/dist/esm/docker/types/ContainerState.js +1 -0
  223. package/dist/esm/docker/types/ContainerStats.js +1 -0
  224. package/dist/esm/docker/types/DockerOutputCallback.js +1 -0
  225. package/dist/esm/docker/types/ImageConfig.js +1 -0
  226. package/dist/esm/docker/types/ImageExposePort.js +1 -0
  227. package/dist/esm/docker/types/NetworkInfo.js +1 -0
  228. package/dist/esm/docker/types/RepositoryTag.js +1 -0
  229. package/dist/esm/exports/Docker.js +73 -0
  230. package/dist/types/client/BuildContext.d.ts +22 -0
  231. package/dist/types/client/BuildKitProgress.d.ts +81 -0
  232. package/dist/types/client/DockerClient.d.ts +196 -0
  233. package/dist/types/client/DockerConnection.d.ts +154 -0
  234. package/dist/types/client/DockerIgnore.d.ts +44 -0
  235. package/dist/types/client/DockerRequestError.d.ts +17 -0
  236. package/dist/types/client/DockerStreams.d.ts +35 -0
  237. package/dist/types/client/types/ContainerCreateResponse.d.ts +7 -0
  238. package/dist/types/client/types/ContainerStopQuery.d.ts +13 -0
  239. package/dist/types/client/types/DeviceMapping.d.ts +8 -0
  240. package/dist/types/client/types/IdResponse.d.ts +6 -0
  241. package/dist/types/client/types/NetworkCreateResponse.d.ts +7 -0
  242. package/dist/types/client/types/PortBinding.d.ts +10 -0
  243. package/dist/types/docker/ConnectionOptionsBuilder.d.ts +128 -0
  244. package/dist/types/docker/Docker.d.ts +301 -0
  245. package/dist/types/docker/exceptions/DockerConnectionException.d.ts +9 -0
  246. package/dist/types/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
  247. package/dist/types/docker/exceptions/DockerImageBuildException.d.ts +9 -0
  248. package/dist/types/docker/exceptions/DockerImageImportException.d.ts +9 -0
  249. package/dist/types/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
  250. package/dist/types/docker/exceptions/DockerImagePullException.d.ts +9 -0
  251. package/dist/types/docker/exceptions/DockerImagePushException.d.ts +8 -0
  252. package/dist/types/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
  253. package/dist/types/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
  254. package/dist/types/docker/exceptions/DockerRequestException.d.ts +22 -0
  255. package/dist/types/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
  256. package/dist/types/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
  257. package/dist/types/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
  258. package/dist/types/docker/interfaces/IDockerKeyObject.d.ts +14 -0
  259. package/dist/types/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
  260. package/dist/types/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
  261. package/dist/types/docker/lib/DockerContainer.d.ts +315 -0
  262. package/dist/types/docker/lib/DockerContainerTTY.d.ts +99 -0
  263. package/dist/types/docker/lib/DockerImage.d.ts +153 -0
  264. package/dist/types/docker/lib/EngineSettings.d.ts +41 -0
  265. package/dist/types/docker/lib/ParseBaseImages.d.ts +9 -0
  266. package/dist/types/docker/lib/ParseEnvToRecord.d.ts +14 -0
  267. package/dist/types/docker/lib/ParseRepositoryTag.d.ts +17 -0
  268. package/dist/types/docker/lib/RegistryAuth.d.ts +8 -0
  269. package/dist/types/docker/options/DockerPruneOptions.d.ts +38 -0
  270. package/dist/types/docker/options/auth/DockerAuthOptions.d.ts +46 -0
  271. package/dist/types/docker/options/container/ContainerCommitOptions.d.ts +28 -0
  272. package/dist/types/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
  273. package/dist/types/docker/options/container/ContainerExecOptions.d.ts +26 -0
  274. package/dist/types/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
  275. package/dist/types/docker/options/container/ContainerKillOptions.d.ts +25 -0
  276. package/dist/types/docker/options/container/ContainerLogsOptions.d.ts +48 -0
  277. package/dist/types/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
  278. package/dist/types/docker/options/container/ContainerSettingOptions.d.ts +137 -0
  279. package/dist/types/docker/options/container/ContainerStopOptions.d.ts +28 -0
  280. package/dist/types/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  281. package/dist/types/docker/options/image/ImageBuildOptions.d.ts +117 -0
  282. package/dist/types/docker/options/image/ImageExportOptions.d.ts +33 -0
  283. package/dist/types/docker/options/image/ImageImportOptions.d.ts +28 -0
  284. package/dist/types/docker/options/image/ImagePullOptions.d.ts +49 -0
  285. package/dist/types/docker/options/image/ImagePushOptions.d.ts +41 -0
  286. package/dist/types/docker/options/image/ImageRemoveOptions.d.ts +26 -0
  287. package/dist/types/docker/options/image/ImageTagOptions.d.ts +25 -0
  288. package/dist/types/docker/options/network/NetworkCreateOptions.d.ts +54 -0
  289. package/dist/types/docker/types/ContainerBind.d.ts +19 -0
  290. package/dist/types/docker/types/ContainerCapability.d.ts +286 -0
  291. package/dist/types/docker/types/ContainerConfig.d.ts +67 -0
  292. package/dist/types/docker/types/ContainerDevice.d.ts +19 -0
  293. package/dist/types/docker/types/ContainerExecResult.d.ts +20 -0
  294. package/dist/types/docker/types/ContainerNetwork.d.ts +46 -0
  295. package/dist/types/docker/types/ContainerPort.d.ts +25 -0
  296. package/dist/types/docker/types/ContainerRestartPolicy.d.ts +11 -0
  297. package/dist/types/docker/types/ContainerState.d.ts +48 -0
  298. package/dist/types/docker/types/ContainerStats.d.ts +408 -0
  299. package/dist/types/docker/types/DockerOutputCallback.d.ts +8 -0
  300. package/dist/types/docker/types/ImageConfig.d.ts +34 -0
  301. package/dist/types/docker/types/ImageExposePort.d.ts +17 -0
  302. package/dist/types/docker/types/NetworkInfo.d.ts +59 -0
  303. package/dist/types/docker/types/RepositoryTag.d.ts +15 -0
  304. package/dist/types/exports/Docker.d.ts +73 -0
  305. package/package.json +57 -0
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DockerImage = void 0;
13
+ const core_1 = require("@lakutata/core");
14
+ const di_1 = require("@lakutata/core/decorator/di");
15
+ const DockerStreams_js_1 = require("../../client/DockerStreams.js");
16
+ const Time_1 = require("@lakutata/utils/Time");
17
+ const ImageTagOptions_js_1 = require("../options/image/ImageTagOptions.js");
18
+ const dto_1 = require("@lakutata/core/decorator/dto");
19
+ const ImageExportOptions_js_1 = require("../options/image/ImageExportOptions.js");
20
+ const node_fs_1 = require("node:fs");
21
+ const promises_1 = require("stream/promises");
22
+ const DockerImageRepoTagNotFoundException_js_1 = require("../exceptions/DockerImageRepoTagNotFoundException.js");
23
+ const ImageRemoveOptions_js_1 = require("../options/image/ImageRemoveOptions.js");
24
+ const ImagePushOptions_js_1 = require("../options/image/ImagePushOptions.js");
25
+ const DockerImagePushException_js_1 = require("../exceptions/DockerImagePushException.js");
26
+ const utils_1 = require("@lakutata/utils");
27
+ const ParseRepositoryTag_js_1 = require("./ParseRepositoryTag.js");
28
+ const ParseEnvToRecord_js_1 = require("./ParseEnvToRecord.js");
29
+ const ContainerSettingOptions_js_1 = require("../options/container/ContainerSettingOptions.js");
30
+ const RegistryAuth_js_1 = require("./RegistryAuth.js");
31
+ /**
32
+ * An image of the Docker daemon, with its tags, platform, size and configuration as inspected, and its operations: tag,
33
+ * export, push, remove, and run a container. It is not created with `new`: {@link Docker.getImage},
34
+ * {@link Docker.listImages}, {@link Docker.pullImage}, {@link Docker.buildImage}, {@link Docker.importImage} and
35
+ * {@link DockerContainer.commit} return it.
36
+ *
37
+ * Its properties are a snapshot, taken when it is obtained and refreshed by `tag()` and `push()`. Its operations reject
38
+ * with {@link DockerImageNotFoundException} when the image was removed, with {@link DockerRequestException} when the
39
+ * daemon refuses them otherwise (used by a container: HTTP 409), and with the network error of Node.js when the daemon
40
+ * cannot be reached.
41
+ * @example
42
+ * ```typescript
43
+ * import {type Docker, type DockerContainer, type DockerImage} from 'lakutata/com/docker'
44
+ *
45
+ * declare const docker: Docker
46
+ *
47
+ * const image: DockerImage = await docker.buildImage({workdir: '/srv/app', files: ['Dockerfile', 'src', 'package.json'], repoTag: 'app:1.0.0'})
48
+ * console.log(image.id, image.platform, image.size, image.config.ports)
49
+ * await image.tag({repo: 'registry.example.com/team/app', tag: '1.0.0'})
50
+ * await image.push({
51
+ * repo: 'registry.example.com/team/app',
52
+ * tag: '1.0.0',
53
+ * auth: {serverAddress: 'registry.example.com', username: 'ci', password: 'secret'}
54
+ * })
55
+ * await image.export({destination: '/tmp/app-1.0.0.tar', repoTag: 'app:1.0.0'})
56
+ * const container: DockerContainer = await image.run({name: 'app', ports: [{port: 3000, type: 'tcp', hostPorts: [3000]}]})
57
+ * console.log(container.state.status)
58
+ * ```
59
+ */
60
+ let DockerImage = class DockerImage extends core_1.Provider {
61
+ #abortController = new AbortController();
62
+ /**
63
+ * Inspect the image.
64
+ * @throws {DockerImageNotFoundException} When the image does not exist.
65
+ * @protected
66
+ */
67
+ async init() {
68
+ await this.syncImageInfo();
69
+ }
70
+ /**
71
+ * Abort the export in progress of the object (the image itself is left as it is).
72
+ * @protected
73
+ */
74
+ async destroy() {
75
+ this.#abortController.abort();
76
+ }
77
+ /**
78
+ * Refresh the properties from the daemon's inspection of the image.
79
+ * @throws {DockerImageNotFoundException} When the image does not exist.
80
+ * @protected
81
+ */
82
+ async syncImageInfo() {
83
+ const inspectInfo = await this.getClient().inspectImage(this.id);
84
+ this.repoTags = inspectInfo.RepoTags;
85
+ this.createdAt = new Time_1.Time(inspectInfo.Created);
86
+ this.arch = inspectInfo.Architecture;
87
+ this.os = inspectInfo.Os;
88
+ this.platform = `${this.os}/${this.arch}`;
89
+ this.size = inspectInfo.Size;
90
+ const exposePorts = [];
91
+ const exposePortMap = new Map();
92
+ if (inspectInfo.Config.ExposedPorts) {
93
+ Object.keys(inspectInfo.Config.ExposedPorts).forEach((portWithType) => {
94
+ const portInfos = portWithType.split('/');
95
+ const port = parseInt(portInfos[0]);
96
+ const type = (0, utils_1.As)(portInfos[1].toLowerCase());
97
+ if (!exposePortMap.has(port))
98
+ exposePortMap.set(port, { tcp: false, udp: false });
99
+ const portType = exposePortMap.get(port);
100
+ portType[type] = true;
101
+ exposePortMap.set(port, portType);
102
+ });
103
+ exposePortMap.forEach((portType, port) => exposePorts.push({ port: port, ...portType }));
104
+ }
105
+ this.config = {
106
+ hostname: inspectInfo.Config.Hostname,
107
+ user: inspectInfo.Config.User,
108
+ env: (0, ParseEnvToRecord_js_1.parseEnvToRecord)(inspectInfo.Config.Env),
109
+ cmd: inspectInfo.Config.Cmd,
110
+ entrypoint: inspectInfo.Config.Entrypoint
111
+ ? Array.isArray(inspectInfo.Config.Entrypoint)
112
+ ? inspectInfo.Config.Entrypoint
113
+ : [inspectInfo.Config.Entrypoint]
114
+ : [],
115
+ volumes: inspectInfo.Config.Volumes ? Object.keys(inspectInfo.Config.Volumes) : [],
116
+ ports: exposePorts
117
+ };
118
+ }
119
+ /**
120
+ * Add a tag to the image, as `docker tag`, then refresh its properties. A tag already given to another image moves to
121
+ * this one.
122
+ * @param options The repository (`registry.example.com/team/app`) and the tag (`latest` by default).
123
+ * @throws {DockerImageNotFoundException} When the image was removed.
124
+ * @throws {DockerRequestException} When the name is invalid (HTTP 400).
125
+ */
126
+ async tag(options) {
127
+ try {
128
+ await this.getClient().tagImage(this.id, { repo: options.repo, tag: options.tag });
129
+ await this.syncImageInfo();
130
+ }
131
+ catch (e) {
132
+ if (!(0, utils_1.isAbortError)(e))
133
+ throw e;
134
+ }
135
+ }
136
+ /**
137
+ * Save the image as a tar archive, as `docker save`, which {@link Docker.importImage} loads. With `repoTag`, the
138
+ * archive holds that tag (restored when it is loaded); without it, the image is saved by ID, without its tags.
139
+ * @param options The `destination` (a file path, created or overwritten, or a writable stream, ended after the
140
+ * archive), the tag saved (`repoTag`), and `createRepoTagIfNotExists` (`true` by default) to add that tag to the image
141
+ * when it does not have it.
142
+ * @throws {DockerImageRepoTagNotFoundException} When the image does not have `repoTag` and
143
+ * `createRepoTagIfNotExists` is `false`.
144
+ * @throws {DockerImageNotFoundException} When the image was removed.
145
+ * @throws {Error} The error of the destination.
146
+ */
147
+ async export(options) {
148
+ try {
149
+ let name = this.id;
150
+ if (options.repoTag) {
151
+ if (!this.repoTags.includes(options.repoTag)) {
152
+ if (!options.createRepoTagIfNotExists)
153
+ throw new DockerImageRepoTagNotFoundException_js_1.DockerImageRepoTagNotFoundException('The current image does not contain the RepoTag of {0}', [options.repoTag]);
154
+ const { repo, tag } = (0, ParseRepositoryTag_js_1.parseRepositoryTag)(options.repoTag);
155
+ await this.tag({ repo: repo, tag: tag });
156
+ }
157
+ name = options.repoTag;
158
+ }
159
+ const readableStream = await this.getClient().exportImage(name);
160
+ const destStream = typeof options.destination === 'string'
161
+ ? (0, node_fs_1.createWriteStream)(options.destination, { signal: this.#abortController.signal })
162
+ : options.destination;
163
+ await (0, promises_1.pipeline)(readableStream, destStream);
164
+ }
165
+ catch (e) {
166
+ if (!(0, utils_1.isAbortError)(e))
167
+ throw e;
168
+ }
169
+ }
170
+ /**
171
+ * Push the image to its registry, as `docker push`, and wait for its end. The image is first tagged `repo:tag` (the
172
+ * tag is kept afterwards).
173
+ * @param options The repository, with its registry (`registry.example.com/team/app`); the tag (`latest` by default);
174
+ * the registry credentials; and a callback receiving each progress message.
175
+ * @throws {DockerImagePushException} When the registry refuses the push (refused credentials, a repository not
176
+ * found).
177
+ * @throws {DockerImageNotFoundException} When the image was removed.
178
+ * @throws {DockerRequestException} When the daemon refuses to push it.
179
+ */
180
+ async push(options) {
181
+ const tag = options.tag ? options.tag : 'latest';
182
+ await this.tag({ repo: options.repo, tag: tag });
183
+ await this.syncImageInfo();
184
+ let pushException;
185
+ const readableStream = await this.getClient().pushImage(options.repo, { tag: tag }, (0, RegistryAuth_js_1.registryAuth)(options.auth));
186
+ await (0, DockerStreams_js_1.followProgress)(readableStream, (outputObject) => {
187
+ if (outputObject.error && !pushException)
188
+ pushException = new DockerImagePushException_js_1.DockerImagePushException(outputObject.error);
189
+ if (options.outputCallback)
190
+ options.outputCallback(outputObject);
191
+ });
192
+ if (pushException)
193
+ throw pushException;
194
+ }
195
+ /**
196
+ * Remove the image, as `docker rmi -f` by default: forced, it is removed with all its tags, even when a stopped
197
+ * container uses it.
198
+ * @param options `force` (`true` by default; `false` refuses an image with several tags or used by a container) and
199
+ * `noprune` (keeps its untagged parent images; `false` by default).
200
+ * @throws {DockerImageNotFoundException} When the image was already removed.
201
+ * @throws {DockerRequestException} When it is used by a running container or, without `force`, by any container or
202
+ * with several tags (HTTP 409).
203
+ */
204
+ async remove(options) {
205
+ try {
206
+ await this.getClient().removeImage(this.id, { force: options?.force, noprune: options?.noprune });
207
+ }
208
+ catch (e) {
209
+ if (!(0, utils_1.isAbortError)(e))
210
+ throw e;
211
+ }
212
+ }
213
+ /**
214
+ * Create a container from the image, for its platform, then start it, as `docker run -d`.
215
+ * @param options The container's settings: name, command, environment, ports, binds, devices, networks, limits…
216
+ * @returns The container, started.
217
+ * @throws {DockerRequestException} When the name is already used (HTTP 409), or the start fails (HTTP 500: a command
218
+ * not found, a port already used); the container then stays created.
219
+ * @throws {DockerNetworkNotFoundException} When a network of the settings is not found.
220
+ * @throws {InvalidMethodAcceptException} When the settings are invalid.
221
+ */
222
+ async run(options) {
223
+ const container = await this.getDocker().createContainer(this.id, this.platform, options);
224
+ await container.start();
225
+ return container;
226
+ }
227
+ };
228
+ exports.DockerImage = DockerImage;
229
+ __decorate([
230
+ (0, di_1.Configurable)(core_1.DTO.Function()),
231
+ __metadata("design:type", Function)
232
+ ], DockerImage.prototype, "getClient", void 0);
233
+ __decorate([
234
+ (0, di_1.Configurable)(core_1.DTO.Function()),
235
+ __metadata("design:type", Function)
236
+ ], DockerImage.prototype, "getDocker", void 0);
237
+ __decorate([
238
+ (0, di_1.Configurable)(core_1.DTO.String()),
239
+ __metadata("design:type", String)
240
+ ], DockerImage.prototype, "id", void 0);
241
+ __decorate([
242
+ (0, dto_1.Accept)(ImageTagOptions_js_1.ImageTagOptions.required()),
243
+ __metadata("design:type", Function),
244
+ __metadata("design:paramtypes", [ImageTagOptions_js_1.ImageTagOptions]),
245
+ __metadata("design:returntype", Promise)
246
+ ], DockerImage.prototype, "tag", null);
247
+ __decorate([
248
+ (0, dto_1.Accept)(ImageExportOptions_js_1.ImageExportOptions.required()),
249
+ __metadata("design:type", Function),
250
+ __metadata("design:paramtypes", [ImageExportOptions_js_1.ImageExportOptions]),
251
+ __metadata("design:returntype", Promise)
252
+ ], DockerImage.prototype, "export", null);
253
+ __decorate([
254
+ (0, dto_1.Accept)(ImagePushOptions_js_1.ImagePushOptions.required()),
255
+ __metadata("design:type", Function),
256
+ __metadata("design:paramtypes", [ImagePushOptions_js_1.ImagePushOptions]),
257
+ __metadata("design:returntype", Promise)
258
+ ], DockerImage.prototype, "push", null);
259
+ __decorate([
260
+ (0, dto_1.Accept)(ImageRemoveOptions_js_1.ImageRemoveOptions.optional().default({ force: true })),
261
+ __metadata("design:type", Function),
262
+ __metadata("design:paramtypes", [ImageRemoveOptions_js_1.ImageRemoveOptions]),
263
+ __metadata("design:returntype", Promise)
264
+ ], DockerImage.prototype, "remove", null);
265
+ __decorate([
266
+ (0, dto_1.Accept)(ContainerSettingOptions_js_1.ContainerSettingOptions.required()),
267
+ __metadata("design:type", Function),
268
+ __metadata("design:paramtypes", [ContainerSettingOptions_js_1.ContainerSettingOptions]),
269
+ __metadata("design:returntype", Promise)
270
+ ], DockerImage.prototype, "run", null);
271
+ exports.DockerImage = DockerImage = __decorate([
272
+ (0, di_1.Transient)()
273
+ ], DockerImage);
@@ -0,0 +1,41 @@
1
+ import { type ContainerSettingOptions } from '../options/container/ContainerSettingOptions.js';
2
+ import { type ContainerRestartPolicy } from '../types/ContainerRestartPolicy.js';
3
+ import { type DeviceMapping } from '../../client/types/DeviceMapping.js';
4
+ import { type PortBinding } from '../../client/types/PortBinding.js';
5
+ /**
6
+ * The restart policy of the Engine API: "on-failure:3" is the policy on-failure with 3 retries at most
7
+ * @param restartPolicy
8
+ */
9
+ export declare function engineRestartPolicy(restartPolicy: ContainerRestartPolicy): {
10
+ Name: string;
11
+ MaximumRetryCount?: number;
12
+ };
13
+ /**
14
+ * The restart policy of a container, from the one of the Engine API
15
+ * @param restartPolicy
16
+ */
17
+ export declare function parseRestartPolicy(restartPolicy?: {
18
+ Name?: string;
19
+ MaximumRetryCount?: number;
20
+ } | null): ContainerRestartPolicy;
21
+ /**
22
+ * The port bindings of the Engine API ("80/tcp": [{HostPort: "8080"}]): each host port once, null for a port published
23
+ * on no host port
24
+ * @param ports
25
+ */
26
+ export declare function enginePortBindings(ports: NonNullable<ContainerSettingOptions['ports']>): Record<string, PortBinding[] | null>;
27
+ /**
28
+ * The bind mounts of the Engine API ("hostPath:containerPath:rw")
29
+ * @param binds
30
+ */
31
+ export declare function engineBinds(binds: NonNullable<ContainerSettingOptions['binds']>): string[];
32
+ /**
33
+ * The devices of the Engine API
34
+ * @param devices
35
+ */
36
+ export declare function engineDevices(devices: NonNullable<ContainerSettingOptions['devices']>): DeviceMapping[];
37
+ /**
38
+ * The endpoints of the Engine API, by network: the static addresses given, none on the reserved networks
39
+ * @param networks
40
+ */
41
+ export declare function engineEndpoints(networks: NonNullable<ContainerSettingOptions['networks']>): Record<string, Record<string, unknown>>;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.engineRestartPolicy = engineRestartPolicy;
4
+ exports.parseRestartPolicy = parseRestartPolicy;
5
+ exports.enginePortBindings = enginePortBindings;
6
+ exports.engineBinds = engineBinds;
7
+ exports.engineDevices = engineDevices;
8
+ exports.engineEndpoints = engineEndpoints;
9
+ /**
10
+ * The networks Docker creates itself: the addresses of their endpoints cannot be set
11
+ */
12
+ const RESERVED_NETWORKS = ['bridge', 'host', 'none'];
13
+ /**
14
+ * The restart policy of the Engine API: "on-failure:3" is the policy on-failure with 3 retries at most
15
+ * @param restartPolicy
16
+ */
17
+ function engineRestartPolicy(restartPolicy) {
18
+ const [name, retries] = restartPolicy.split(':');
19
+ return retries === undefined ? { Name: name } : { Name: name, MaximumRetryCount: Number.parseInt(retries, 10) };
20
+ }
21
+ /**
22
+ * The restart policy of a container, from the one of the Engine API
23
+ * @param restartPolicy
24
+ */
25
+ function parseRestartPolicy(restartPolicy) {
26
+ if (!restartPolicy?.Name)
27
+ return '';
28
+ if (restartPolicy.Name === 'on-failure' && restartPolicy.MaximumRetryCount)
29
+ return `on-failure:${restartPolicy.MaximumRetryCount}`;
30
+ return restartPolicy.Name;
31
+ }
32
+ /**
33
+ * The port bindings of the Engine API ("80/tcp": [{HostPort: "8080"}]): each host port once, null for a port published
34
+ * on no host port
35
+ * @param ports
36
+ */
37
+ function enginePortBindings(ports) {
38
+ const hostPortsMap = new Map();
39
+ for (const port of ports) {
40
+ const key = `${port.port}/${port.type}`;
41
+ const hostPorts = hostPortsMap.get(key) ?? new Set();
42
+ port.hostPorts?.forEach((hostPort) => hostPorts.add(hostPort));
43
+ hostPortsMap.set(key, hostPorts);
44
+ }
45
+ const portBindings = {};
46
+ hostPortsMap.forEach((hostPorts, key) => {
47
+ portBindings[key] = hostPorts.size ? [...hostPorts].map((hostPort) => ({ HostPort: hostPort.toString() })) : null;
48
+ });
49
+ return portBindings;
50
+ }
51
+ /**
52
+ * The bind mounts of the Engine API ("hostPath:containerPath:rw")
53
+ * @param binds
54
+ */
55
+ function engineBinds(binds) {
56
+ return binds.map((bind) => `${bind.hostPath}:${bind.containerPath}:${bind.rw ? 'rw' : 'ro'}`);
57
+ }
58
+ /**
59
+ * The devices of the Engine API
60
+ * @param devices
61
+ */
62
+ function engineDevices(devices) {
63
+ return devices.map((device) => ({
64
+ PathOnHost: device.hostPath,
65
+ PathInContainer: device.containerPath,
66
+ CgroupPermissions: device.cgroupPermissions
67
+ }));
68
+ }
69
+ /**
70
+ * The endpoints of the Engine API, by network: the static addresses given, none on the reserved networks
71
+ * @param networks
72
+ */
73
+ function engineEndpoints(networks) {
74
+ const endpoints = {};
75
+ for (const network of networks) {
76
+ endpoints[network.networkName] = RESERVED_NETWORKS.includes(network.networkName)
77
+ ? {}
78
+ : {
79
+ IPAMConfig: {
80
+ IPv4Address: network.ip ? network.ip : undefined,
81
+ IPv6Address: network.ipv6 ? network.ipv6 : undefined
82
+ }
83
+ };
84
+ }
85
+ return endpoints;
86
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The images of the FROM instructions of a Dockerfile, pulled before a build with credentials: their flags (--platform)
3
+ * and their stage names (AS build) are skipped, the stages of the Dockerfile and scratch are not images, the variables
4
+ * are the ARG declared before the first FROM (with their defaults) and the build arguments. The images whose variables
5
+ * are unknown are skipped
6
+ * @param dockerfile the content of the Dockerfile
7
+ * @param buildargs
8
+ */
9
+ export declare function parseBaseImages(dockerfile: string, buildargs?: Record<string, string>): string[];
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseBaseImages = parseBaseImages;
4
+ /**
5
+ * The images of the FROM instructions of a Dockerfile, pulled before a build with credentials: their flags (--platform)
6
+ * and their stage names (AS build) are skipped, the stages of the Dockerfile and scratch are not images, the variables
7
+ * are the ARG declared before the first FROM (with their defaults) and the build arguments. The images whose variables
8
+ * are unknown are skipped
9
+ * @param dockerfile the content of the Dockerfile
10
+ * @param buildargs
11
+ */
12
+ function parseBaseImages(dockerfile, buildargs = {}) {
13
+ //The instructions continued on the next lines (a backslash at the end of a line)
14
+ const instructions = dockerfile.replace(/\\\r?\n/g, ' ').split(/\r?\n/).map((line) => line.trim()).filter((line) => !!line && !line.startsWith('#'));
15
+ const variables = {};
16
+ const stages = new Set();
17
+ const images = [];
18
+ let beforeFirstFrom = true;
19
+ for (const instruction of instructions) {
20
+ const [keyword, ...rest] = instruction.split(/\s+/);
21
+ if (keyword.toUpperCase() === 'ARG' && beforeFirstFrom) {
22
+ for (const declaration of rest) {
23
+ const [name, value] = declaration.split(/=(.*)/s);
24
+ if (buildargs[name] !== undefined)
25
+ variables[name] = buildargs[name];
26
+ else if (value !== undefined)
27
+ variables[name] = value.replace(/^["']|["']$/g, '');
28
+ }
29
+ }
30
+ if (keyword.toUpperCase() !== 'FROM')
31
+ continue;
32
+ beforeFirstFrom = false;
33
+ const words = rest.filter((word) => !word.startsWith('--'));
34
+ const [reference, as, stage] = words;
35
+ if (as?.toUpperCase() === 'AS' && stage)
36
+ stages.add(stage.toLowerCase());
37
+ if (!reference)
38
+ continue;
39
+ let unknown = false;
40
+ const image = reference.replace(/\$\{?([A-Za-z_][A-Za-z0-9_]*)}?/g, (_, name) => {
41
+ if (variables[name] === undefined)
42
+ unknown = true;
43
+ return variables[name] ?? '';
44
+ });
45
+ if (unknown || !image || image.toLowerCase() === 'scratch' || stages.has(image.toLowerCase()) || images.includes(image))
46
+ continue;
47
+ images.push(image);
48
+ }
49
+ return images;
50
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Turn a list of environment variables as the Engine API gives them (`['PATH=/usr/bin', 'MODE=a=b']`) into a record by
3
+ * name. A variable is split at its first `=`; an entry without `=` is skipped; a repeated name keeps its last value.
4
+ * @param rawEnv The `NAME=value` entries; `null` or `undefined` for none.
5
+ * @returns The values by name (`{PATH: '/usr/bin', MODE: 'a=b'}`).
6
+ * @example
7
+ * ```typescript
8
+ * import {parseEnvToRecord} from 'lakutata/com/docker'
9
+ *
10
+ * const env: Record<string, string> = parseEnvToRecord(['PATH=/usr/bin', 'MODE=a=b', 'EMPTY='])
11
+ * console.log(env) //{PATH: '/usr/bin', MODE: 'a=b', EMPTY: ''}
12
+ * ```
13
+ */
14
+ export declare function parseEnvToRecord(rawEnv?: string[] | null): Record<string, string>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseEnvToRecord = parseEnvToRecord;
4
+ /**
5
+ * Turn a list of environment variables as the Engine API gives them (`['PATH=/usr/bin', 'MODE=a=b']`) into a record by
6
+ * name. A variable is split at its first `=`; an entry without `=` is skipped; a repeated name keeps its last value.
7
+ * @param rawEnv The `NAME=value` entries; `null` or `undefined` for none.
8
+ * @returns The values by name (`{PATH: '/usr/bin', MODE: 'a=b'}`).
9
+ * @example
10
+ * ```typescript
11
+ * import {parseEnvToRecord} from 'lakutata/com/docker'
12
+ *
13
+ * const env: Record<string, string> = parseEnvToRecord(['PATH=/usr/bin', 'MODE=a=b', 'EMPTY='])
14
+ * console.log(env) //{PATH: '/usr/bin', MODE: 'a=b', EMPTY: ''}
15
+ * ```
16
+ */
17
+ function parseEnvToRecord(rawEnv) {
18
+ const environments = {};
19
+ for (const envString of rawEnv ?? []) {
20
+ const splitPos = envString.indexOf('=');
21
+ if (splitPos !== -1)
22
+ environments[envString.substring(0, splitPos)] = envString.substring(splitPos + 1);
23
+ }
24
+ return environments;
25
+ }
@@ -0,0 +1,17 @@
1
+ import { type RepositoryTag } from '../types/RepositoryTag.js';
2
+ /**
3
+ * Split an image reference into its repository and its tag (or digest). A digest (`@`) wins over a tag; the port of a
4
+ * registry (`registry:5000/app`) is not taken for a tag.
5
+ * @param input The image reference: `alpine`, `alpine:3.20`, `registry.example.com:5000/team/app:1.0`,
6
+ * `alpine@sha256:…`.
7
+ * @returns The repository, and the tag (or the digest, without its `@`) when the reference has one.
8
+ * @example
9
+ * ```typescript
10
+ * import {parseRepositoryTag, type RepositoryTag} from 'lakutata/com/docker'
11
+ *
12
+ * const reference: RepositoryTag = parseRepositoryTag('registry.example.com:5000/team/app:1.0')
13
+ * console.log(reference) //{repo: 'registry.example.com:5000/team/app', tag: '1.0'}
14
+ * console.log(parseRepositoryTag('registry.example.com:5000/team/app')) //{repo: 'registry.example.com:5000/team/app'}
15
+ * ```
16
+ */
17
+ export declare function parseRepositoryTag(input: string): RepositoryTag;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRepositoryTag = parseRepositoryTag;
4
+ /**
5
+ * Split an image reference into its repository and its tag (or digest). A digest (`@`) wins over a tag; the port of a
6
+ * registry (`registry:5000/app`) is not taken for a tag.
7
+ * @param input The image reference: `alpine`, `alpine:3.20`, `registry.example.com:5000/team/app:1.0`,
8
+ * `alpine@sha256:…`.
9
+ * @returns The repository, and the tag (or the digest, without its `@`) when the reference has one.
10
+ * @example
11
+ * ```typescript
12
+ * import {parseRepositoryTag, type RepositoryTag} from 'lakutata/com/docker'
13
+ *
14
+ * const reference: RepositoryTag = parseRepositoryTag('registry.example.com:5000/team/app:1.0')
15
+ * console.log(reference) //{repo: 'registry.example.com:5000/team/app', tag: '1.0'}
16
+ * console.log(parseRepositoryTag('registry.example.com:5000/team/app')) //{repo: 'registry.example.com:5000/team/app'}
17
+ * ```
18
+ */
19
+ function parseRepositoryTag(input) {
20
+ let separatorPos;
21
+ const digestPos = input.indexOf('@');
22
+ const colonPos = input.lastIndexOf(':');
23
+ // @ symbol is more important
24
+ if (digestPos >= 0) {
25
+ separatorPos = digestPos;
26
+ }
27
+ else if (colonPos >= 0) {
28
+ separatorPos = colonPos;
29
+ }
30
+ else {
31
+ // no colon nor @
32
+ return {
33
+ repo: input
34
+ };
35
+ }
36
+ // last colon is either the tag (or part of a port designation)
37
+ const tag = input.slice(separatorPos + 1);
38
+ // if it contains a / its not a tag and is part of the url
39
+ if (tag.indexOf('/') === -1) {
40
+ return {
41
+ repo: input.slice(0, separatorPos),
42
+ tag: tag
43
+ };
44
+ }
45
+ return {
46
+ repo: input
47
+ };
48
+ }
@@ -0,0 +1,8 @@
1
+ import { type DockerRegistryAuth } from '../../client/DockerClient.js';
2
+ import { type DockerAuthOptions } from '../options/auth/DockerAuthOptions.js';
3
+ /**
4
+ * The registry credentials sent to the daemon (the login, the pulls, the pushes and the builds), the tokens included
5
+ * @param auth
6
+ */
7
+ export declare function registryAuth(auth: DockerAuthOptions): DockerRegistryAuth;
8
+ export declare function registryAuth(auth?: DockerAuthOptions): DockerRegistryAuth | undefined;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registryAuth = registryAuth;
4
+ function registryAuth(auth) {
5
+ if (!auth)
6
+ return undefined;
7
+ return {
8
+ username: auth.username,
9
+ password: auth.password,
10
+ serveraddress: auth.serverAddress,
11
+ email: auth.email,
12
+ identitytoken: auth.identityToken,
13
+ registrytoken: auth.registryToken
14
+ };
15
+ }
@@ -0,0 +1,38 @@
1
+ import { DTO } from '@lakutata/core';
2
+ /**
3
+ * Which unused resources {@link Docker.prune} removes, each kind as its `docker … prune` command does without options.
4
+ * Called without options, it prunes the containers and the images; the networks and the volumes only when asked (the
5
+ * volumes, as `docker system prune --volumes`).
6
+ * @example
7
+ * ```typescript
8
+ * import {Docker} from 'lakutata/com/docker'
9
+ *
10
+ * declare const docker: Docker
11
+ *
12
+ * //The stopped containers and the unused networks, keeping the images and the volumes
13
+ * await docker.prune({containers: true, images: false, networks: true, volumes: false})
14
+ * ```
15
+ */
16
+ export declare class DockerPruneOptions extends DTO {
17
+ /**
18
+ * Remove the stopped containers (`docker container prune`).
19
+ * @default true
20
+ */
21
+ containers?: boolean;
22
+ /**
23
+ * Remove the dangling images, untagged and not used by a container (`docker image prune`, without `--all`).
24
+ * @default true
25
+ */
26
+ images?: boolean;
27
+ /**
28
+ * Remove the networks no container uses (`docker network prune`).
29
+ * @default false
30
+ */
31
+ networks?: boolean;
32
+ /**
33
+ * Remove the volumes no container uses (`docker volume prune`): the anonymous ones only on Docker Engine 23 and
34
+ * later (API 1.42), the named ones too before.
35
+ * @default false
36
+ */
37
+ volumes?: boolean;
38
+ }