Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tarball output format? #128

Closed
bioball opened this issue Jan 28, 2020 · 3 comments · Fixed by #134
Closed

Tarball output format? #128

bioball opened this issue Jan 28, 2020 · 3 comments · Fixed by #134

Comments

@bioball
Copy link

bioball commented Jan 28, 2020

It would be really useful if ko could output images in the tarball format, similar to what you get with docker save. Ideally, ko could output a release.yaml, but output image tarballs rather than publishing them (perhaps writing the tarball to disk?)

Many other tools that build images support outputting docker save-format tarballs; for instance:

@jonjohnsonjr
Copy link
Collaborator

I think that's pretty reasonable. We had some relevant discussion here: #95

If you wanna work around this today and have docker installed, you could roundtrip it through the daemon, e.g.:

$ ko publish -L ./cmd/ko ./cmd/ko/test | xargs docker save > ko.tar
2020/01/28 13:22:24 Using base gcr.io/distroless/static:latest for github.com/google/ko/cmd/ko
2020/01/28 13:22:24 Building github.com/google/ko/cmd/ko
2020/01/28 13:22:28 Loading ko.local/ko-099ba5bcefdead87f92606265fb99ac0:16cde5ae3bcec10b733f6c8bc81b4c5f2acc0e6e83448994534df6ab2112db83
2020/01/28 13:22:28 Loaded ko.local/ko-099ba5bcefdead87f92606265fb99ac0:16cde5ae3bcec10b733f6c8bc81b4c5f2acc0e6e83448994534df6ab2112db83
2020/01/28 13:22:28 Adding tag latest
2020/01/28 13:22:28 Added tag latest
2020/01/28 13:22:29 Using base gcr.io/distroless/static:latest for github.com/google/ko/cmd/ko/test
2020/01/28 13:22:29 Building github.com/google/ko/cmd/ko/test
2020/01/28 13:22:30 Loading ko.local/test-0e3a563dcfe31cd0109fe43c1bf7c91e:66b8d4278a1d35faf75fcb39e2dc780287d93ce41e1354a87be9fd0947421f89
2020/01/28 13:22:30 Loaded ko.local/test-0e3a563dcfe31cd0109fe43c1bf7c91e:66b8d4278a1d35faf75fcb39e2dc780287d93ce41e1354a87be9fd0947421f89
2020/01/28 13:22:30 Adding tag latest
2020/01/28 13:22:30 Added tag latest

$ tar -tvf ko.tar 
-rw-r--r-- root/root       974 1969-12-31 16:00 083d97e600105c9ada5a70068b19150edc0f08ecdfa5bdfa4bf90b80264174ae.json
drwxr-xr-x root/root         0 1969-12-31 16:00 2f686a0f7524711434ea2e5702c0865e88aceeabf1e48f59fdbb2b395675d117/
-rw-r--r-- root/root         3 1969-12-31 16:00 2f686a0f7524711434ea2e5702c0865e88aceeabf1e48f59fdbb2b395675d117/VERSION
-rw-r--r-- root/root       968 1969-12-31 16:00 2f686a0f7524711434ea2e5702c0865e88aceeabf1e48f59fdbb2b395675d117/json
-rw-r--r-- root/root  44232704 1969-12-31 16:00 2f686a0f7524711434ea2e5702c0865e88aceeabf1e48f59fdbb2b395675d117/layer.tar
drwxr-xr-x root/root         0 1969-12-31 16:00 3b0133856a9c05166c634e5ad85cbb39b15ef093210338060cf900ac28df511e/
-rw-r--r-- root/root         3 1969-12-31 16:00 3b0133856a9c05166c634e5ad85cbb39b15ef093210338060cf900ac28df511e/VERSION
-rw-r--r-- root/root       482 1969-12-31 16:00 3b0133856a9c05166c634e5ad85cbb39b15ef093210338060cf900ac28df511e/json
-rw-r--r-- root/root      1536 1969-12-31 16:00 3b0133856a9c05166c634e5ad85cbb39b15ef093210338060cf900ac28df511e/layer.tar
drwxr-xr-x root/root         0 1969-12-31 16:00 774fa74f98be5577ec663365eef7c24c731c18bde0f1d4a44be8ca50372b076c/
-rw-r--r-- root/root         3 1969-12-31 16:00 774fa74f98be5577ec663365eef7c24c731c18bde0f1d4a44be8ca50372b076c/VERSION
-rw-r--r-- root/root       406 1969-12-31 16:00 774fa74f98be5577ec663365eef7c24c731c18bde0f1d4a44be8ca50372b076c/json
-rw-r--r-- root/root   3061760 1969-12-31 16:00 774fa74f98be5577ec663365eef7c24c731c18bde0f1d4a44be8ca50372b076c/layer.tar
drwxr-xr-x root/root         0 1969-12-31 16:00 a54428111bf69ae5f41b6c2ecd306edc87df992b44486e4ab9a0249cff680e13/
-rw-r--r-- root/root         3 1969-12-31 16:00 a54428111bf69ae5f41b6c2ecd306edc87df992b44486e4ab9a0249cff680e13/VERSION
-rw-r--r-- root/root       482 1969-12-31 16:00 a54428111bf69ae5f41b6c2ecd306edc87df992b44486e4ab9a0249cff680e13/json
-rw-r--r-- root/root     66560 1969-12-31 16:00 a54428111bf69ae5f41b6c2ecd306edc87df992b44486e4ab9a0249cff680e13/layer.tar
-rw-r--r-- root/root       958 1969-12-31 16:00 bb7c25e25ee8280479c454ba42a3a22b1eb7a8678da00898376e98f373a67982.json
drwxr-xr-x root/root         0 1969-12-31 16:00 f4e1da5ab6010d8627624de1f1ccc455d56e415ae596fc03132d7234e85757fe/
-rw-r--r-- root/root         3 1969-12-31 16:00 f4e1da5ab6010d8627624de1f1ccc455d56e415ae596fc03132d7234e85757fe/VERSION
-rw-r--r-- root/root       972 1969-12-31 16:00 f4e1da5ab6010d8627624de1f1ccc455d56e415ae596fc03132d7234e85757fe/json
-rw-r--r-- root/root   2203648 1969-12-31 16:00 f4e1da5ab6010d8627624de1f1ccc455d56e415ae596fc03132d7234e85757fe/layer.tar
-rw-r--r-- root/root       904 1969-12-31 16:00 manifest.json
-rw-r--r-- root/root       370 1969-12-31 16:00 repositories

$ tar -Oxf ko.tar manifest.json | jq .
[
  {
    "Config": "bb7c25e25ee8280479c454ba42a3a22b1eb7a8678da00898376e98f373a67982.json",
    "RepoTags": [
      "ko.local/ko-099ba5bcefdead87f92606265fb99ac0:16cde5ae3bcec10b733f6c8bc81b4c5f2acc0e6e83448994534df6ab2112db83"
    ],
    "Layers": [
      "774fa74f98be5577ec663365eef7c24c731c18bde0f1d4a44be8ca50372b076c/layer.tar",
      "3b0133856a9c05166c634e5ad85cbb39b15ef093210338060cf900ac28df511e/layer.tar",
      "2f686a0f7524711434ea2e5702c0865e88aceeabf1e48f59fdbb2b395675d117/layer.tar"
    ]
  },
  {
    "Config": "083d97e600105c9ada5a70068b19150edc0f08ecdfa5bdfa4bf90b80264174ae.json",
    "RepoTags": [
      "ko.local/test-0e3a563dcfe31cd0109fe43c1bf7c91e:66b8d4278a1d35faf75fcb39e2dc780287d93ce41e1354a87be9fd0947421f89"
    ],
    "Layers": [
      "774fa74f98be5577ec663365eef7c24c731c18bde0f1d4a44be8ca50372b076c/layer.tar",
      "a54428111bf69ae5f41b6c2ecd306edc87df992b44486e4ab9a0249cff680e13/layer.tar",
      "f4e1da5ab6010d8627624de1f1ccc455d56e415ae596fc03132d7234e85757fe/layer.tar"
    ]
  }
]

ko publish writes the images it produced to stdout, which is helpful for stuff like this.

@bioball
Copy link
Author

bioball commented Jan 28, 2020

That's a nice workaround! Although, I suspect this doesn't work for most use-cases, where the Docker daemon isn't available. This happens to be my use-case as well.

@jonjohnsonjr
Copy link
Collaborator

where the Docker daemon isn't available

Yeah this is one of the main benefits of ko, so we should definitely pursue #95 and add tarball support as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants