You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
7.5 KiB

  1. ---
  2. openapi: '3.0.0'
  3. info:
  4. title: Blubberoid
  5. description: >
  6. Blubber is a highly opinionated abstraction for container build
  7. configurations.
  8. version: {{ .Version }}
  9. paths:
  10. /v1/{variant}:
  11. post:
  12. summary: >
  13. Generates a valid Dockerfile based on Blubber YAML configuration
  14. provided in the request body and the given variant name.
  15. requestBody:
  16. description: A valid Blubber configuration.
  17. required: true
  18. content:
  19. application/json:
  20. schema:
  21. $ref: '#/components/schemas/v4.Config'
  22. application/yaml:
  23. schema:
  24. type: string
  25. application/x-yaml:
  26. schema:
  27. type: string
  28. responses:
  29. '200':
  30. description: OK. Response body should be a valid Dockerfile.
  31. content:
  32. text/plain:
  33. schema:
  34. type: string
  35. '400':
  36. description: Bad request. The YAML request body failed to parse.
  37. '404':
  38. description: No variant name was provided in the request path.
  39. '422':
  40. description: Provided Blubber config parsed correctly but failed validation.
  41. '5XX':
  42. description: An unexpected service-side error.
  43. x-amples:
  44. - title: Mathoid test variant
  45. request:
  46. params:
  47. variant: test
  48. headers:
  49. Content-Type: application/json
  50. body: {
  51. "version": "v4",
  52. "base": "docker-registry.wikimedia.org/nodejs-slim",
  53. "apt": { "packages": ["librsvg2-2"] },
  54. "lives": { "in": "/srv/service" },
  55. "variants": {
  56. "build": {
  57. "base": "docker-registry.wikimedia.org/nodejs-devel",
  58. "apt": {
  59. "packages": ["librsvg2-dev", "git", "pkg-config", "build-essential"]
  60. },
  61. "node": { "requirements": ["package.json"] },
  62. "runs": { "environment": { "LINK": "g++" } }
  63. },
  64. "test": { "includes": ["build"], "entrypoint": ["npm", "test"] }
  65. }
  66. }
  67. response:
  68. status: 200
  69. headers:
  70. content-type: text/plain
  71. body: /^FROM docker-registry.wikimedia.org\/nodejs-devel/
  72. components:
  73. schemas:
  74. v4.Config:
  75. title: Top-level blubber configuration (version v4)
  76. allOf:
  77. - $ref: '#/components/schemas/v4.CommonConfig'
  78. - type: object
  79. properties:
  80. required: [version, variants]
  81. version:
  82. type: string
  83. description: Blubber configuration version
  84. variants:
  85. type: object
  86. description: Configuration variants (e.g. development, test, production)
  87. additionalProperties: true
  88. # OpenAPI 3.0 supports only v4 of the JSON Schema draft spec and
  89. # cannot define schema for object properties with arbitrary
  90. # names, but the following commented section is included to be
  91. # useful to humans for the time being. It patiently awaits v6
  92. # json schema draft support before its uncommenting.
  93. #
  94. # patternProperties:
  95. # "^[a-zA-Z][a-zA-Z0-9\-\.]+[a-zA-Z0-9]$":
  96. # $ref: '#/components/schemas/v4.VariantConfig'
  97. v4.CommonConfig:
  98. type: object
  99. properties:
  100. base:
  101. type: string
  102. description: Base image reference
  103. apt:
  104. type: object
  105. properties:
  106. packages:
  107. type: array
  108. description: Packages to install from APT sources of base image
  109. items:
  110. type: string
  111. node:
  112. type: object
  113. properties:
  114. env:
  115. type: string
  116. description: Node environment (e.g. production, etc.)
  117. requirements:
  118. type: array
  119. description: Files needed for Node package installation (e.g. package.json, package-lock.json)
  120. items:
  121. type: string
  122. python:
  123. type: object
  124. properties:
  125. version:
  126. type: string
  127. description: Python binary present in the system (e.g. python3)
  128. requirements:
  129. type: array
  130. description: Files needed for Python package installation (e.g. requirements.txt, etc.)
  131. items:
  132. type: string
  133. builder:
  134. type: object
  135. properties:
  136. command:
  137. type: array
  138. description: Command and arguments of an arbitrary build command
  139. items:
  140. type: string
  141. requirements:
  142. type: array
  143. description: Files needed by the build command (e.g. Makefile, ./src/, etc.)
  144. items:
  145. type: string
  146. lives:
  147. type: object
  148. properties:
  149. as:
  150. type: string
  151. description: Owner (name) of application files within the container
  152. uid:
  153. type: integer
  154. description: Owner (UID) of application files within the container
  155. gid:
  156. type: integer
  157. description: Group owner (GID) of application files within the container
  158. in:
  159. type: string
  160. description: Application working directory within the container
  161. runs:
  162. type: object
  163. properties:
  164. as:
  165. type: string
  166. description: Runtime process owner (name) of application entrypoint
  167. uid:
  168. type: integer
  169. description: Runtime process owner (UID) of application entrypoint
  170. gid:
  171. type: integer
  172. description: Runtime process group (GID) of application entrypoint
  173. environment:
  174. type: object
  175. description: Environment variables and values to be set before entrypoint execution
  176. additionalProperties: true
  177. insecurely:
  178. type: boolean
  179. description: Skip dropping of priviledge to the runtime process owner before entrypoint execution
  180. entrypoint:
  181. type: array
  182. description: Runtime entry point command and arguments
  183. items:
  184. type: string
  185. v4.VariantConfig:
  186. allOf:
  187. - $ref: '#/components/schemas/v4.CommonConfig'
  188. - type: object
  189. properties:
  190. includes:
  191. type: array
  192. description: Names of other variants to inherit configuration from
  193. items:
  194. description: Variant name
  195. type: string
  196. copies:
  197. type: string
  198. description: Name of variant from which to copy application files, resulting in a multi-stage build
  199. artifacts:
  200. type: array
  201. items:
  202. type: object
  203. description: Artifacts to copy from another variant, resulting in a multi-stage build
  204. required: [from, source, destination]
  205. properties:
  206. from:
  207. type: string
  208. description: Variant name
  209. source:
  210. type: string
  211. description: Path of files/directories to copy
  212. destination:
  213. type: string
  214. description: Destination path