porter icon indicating copy to clipboard operation
porter copied to clipboard

extract files from bundle

Open prakashmirji opened this issue 2 years ago • 4 comments

What is your question? When we build/create the app bundle, we would like to include a few files ( logo's, docs...etc) as part of the bundle. In the backend, when we examine ( porter explain or inspect..etc) the bundle, we would like to know how to extract the file path and copy the files to different locations in the backend for processing. I am unable to find the docs on achieving this task

What have you tried already? Looked at the output of porter explain and porter inspect commands, didn't find the pointers to find the file paths

Where have you looked already to figure this out? porter.sh/docs under examine bundle section

Was the existing documentation unclear or had gaps? no page has this information

prakashmirji avatar Apr 02 '22 02:04 prakashmirji

I was looking at the cnab spec. The custom extension section mentioned here https://github.com/cnabio/cnab-spec/blob/main/101-bundle-json.md#custom-extensions might help our usecase. So, we can do something like this below block? But how do we get access to /cnab/app filesystem? do we mount that volume onto host?

{
  "custom": {
    "com.example.logo": {
      "icon": "file:///cnab/app/logo.png",
      "iconType": "PNG"
    }
  }
}

prakashmirji avatar Apr 02 '22 03:04 prakashmirji

I've always wanted to have functionality like this where porter helps you copy content out of a bundle. Unfortunately, it's not supported at this time.

What you can do is create a docker container from the bundle's invocation image (porter inspect gives you the reference to it), and then use docker cp to copy files from the container.

  1. Use inspect to find the invocation image reference ghcr.io/getporter/whalegap@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e
~$ porter inspect -r ghcr.io/getporter/whalegap:v0.2.0 -o json
{
  "name": "whalegap",
  "description": "An example bundle that demonstrates how to sneak a whale-sized bundle through an airgap",
  "version": "0.2.0",
  "invocationImages": [
    {
      "imageType": "docker",
      "image": "ghcr.io/getporter/whalegap@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e",
      "contentDigest": "sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e",
      "size": 3059,
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "originalImage": "ghcr.io/getporter/whalegap:3b60146ec27e425b2322da3df3a743a4@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e"
    }
  ],
  1. Run docker create to make a container from the image without starting it
docker create mybundle ghcr.io/getporter/whalegap@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e
  1. Use docker cp to copy files from the container to your computer
docker cp mybundle:/cnab/app/charts .

You can use the custom section of the porter.yaml file to save custom metadata:

custom:
  logo:
    path: /cnab/app/images/logo.png

You can read that data back out when you copy files from the bundle (none of the commands currently expose this custom metadata), by copying either /cnab/app/porter.yaml or /cnab/bundle.json and read it from the custom section, then make additional copy commands to get the files you need.

carolynvs avatar Apr 03 '22 20:04 carolynvs

I've always wanted to have functionality like this where porter helps you copy content out of a bundle. Unfortunately, it's not supported at this time.

What you can do is create a docker container from the bundle's invocation image (porter inspect gives you the reference to it), and then use docker cp to copy files from the container.

  1. Use inspect to find the invocation image reference ghcr.io/getporter/whalegap@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e
~$ porter inspect -r ghcr.io/getporter/whalegap:v0.2.0 -o json
{
  "name": "whalegap",
  "description": "An example bundle that demonstrates how to sneak a whale-sized bundle through an airgap",
  "version": "0.2.0",
  "invocationImages": [
    {
      "imageType": "docker",
      "image": "ghcr.io/getporter/whalegap@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e",
      "contentDigest": "sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e",
      "size": 3059,
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "originalImage": "ghcr.io/getporter/whalegap:3b60146ec27e425b2322da3df3a743a4@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e"
    }
  ],
  1. Run docker create to make a container from the image without starting it
docker create mybundle ghcr.io/getporter/whalegap@sha256:280b2e1ed5b591c2665d6c8b004523b1e3b76a7447c649c8e8621ed126a5437e
  1. Use docker cp to copy files from the container to your computer
docker cp mybundle:/cnab/app/charts .

You can use the custom section of the porter.yaml file to save custom metadata:

custom:
  logo:
    path: /cnab/app/images/logo.png

You can read that data back out when you copy files from the bundle (none of the commands currently expose this custom metadata), by copying either /cnab/app/porter.yaml or /cnab/bundle.json and read it from the custom section, then make additional copy commands to get the files you need.

We also need such a feature. Putting filetype artifacts into container images is stupid When they are sets of files, there is no way to use caching for unchanged content, and neither push nor pull can implement an incremental model. If porter has a clear roadmap for this feature, please let us know

kuanwwang avatar Apr 25 '22 14:04 kuanwwang

Putting filetype artifacts into container images is stupid

@kuanwwang Please do not use language like this when communicating with the Porter project. It's fine to criticize how the project works, and suggestions for improvements are welcome, but words like stupid and other insults are not in-line with our Code of Conduct.

carolynvs avatar Apr 27 '22 15:04 carolynvs