jkcfg / kubernetes

Apache License 2.0
26 stars 6 forks source link

Build image for lib #60

Closed squaremo closed 4 years ago

squaremo commented 4 years ago
squaremo commented 4 years ago

The Makefile now downloads a zip file (if it hasn't already got it), from jkcfg/kubernetes-schema. The latter is derived from instrumenta/kubernetes-json-schema but only has the files needed for validation.

The files themselves are preprocessed by cmd/dedup/main.go, which copies the versions over in ascending order, replacing files with symlinks back to previous versions. This reduces the total size from about 500MB to a bit under 60MB. When copied to a container image, the size is about 100MB (I guess the symlinks count!).

TOD): automated image push.

squaremo commented 4 years ago

The schemas compress well. Here's the summary of

$ npm publish @jkcfg/kubernetes --dry-run
npm notice === Tarball Details === 
npm notice name:          @jkcfg/kubernetes                       
npm notice version:       0.5.1                                   
npm notice package size:  3.9 MB                                  
npm notice unpacked size: 40.2 MB                                 
npm notice shasum:        2bf8bc32485602d87e3c2cc3ac9eb80934d3bdec
npm notice integrity:     sha512-0igdkSZBDD5ix[...]p5gyJ+WpATKqQ==
npm notice total files:   7633

The docker image reports a size of 50MB locally -- but the size shown in DockerHub is 6.7MB, which is well within acceptable bounds.

time jk run -c 'print("foo")' --lib jkcfg/kubernetes

reported 13.5 seconds -- possibly a lot of that is actually expanding the image layer, rather than downloading it. (On the second run of course, it was instantaneous -- yay).