Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Exporting the helloworld example. #610

Closed
jayunit100 opened this issue Jan 3, 2019 · 7 comments
Closed

Exporting the helloworld example. #610

jayunit100 opened this issue Jan 3, 2019 · 7 comments

Comments

@jayunit100
Copy link

jayunit100 commented Jan 3, 2019

The first thing I tried to do with duffle was export the helloworld example. The reason I tried this is its one of the main value-add of CNAB over pure deployers like helm.

So, here's what I ran into.. Mostly confusion around bundle.json vs. duffle.json (see #609 #330 #329 for related issues. This might be simply another version of #609.

I can build the example. I tried manually making a bundle.json so I could export it but there was a complaint that the .cnab file didnt exist.

Is there any documentation on how to build a .cnab file from a duffle.json, so that I can try exporting it?

➜  helloworld git:(master) ✗ duffle build ./
Step 1/6 : FROM alpine:latest
 ---> 3f53bb00af94
Step 2/6 : RUN apk update
 ---> Using cache
 ---> e808ff8b34a5
Step 3/6 : RUN apk add -u bash
 ---> Using cache
 ---> ef757e4463ff
Step 4/6 : COPY Dockerfile /cnab/Dockerfile
 ---> Using cache
 ---> 61707a2ae06a
Step 5/6 : COPY app /cnab/app
 ---> Using cache
 ---> ab748f5a1ef6
Step 6/6 : CMD ["/cnab/app/run"]
 ---> Using cache
 ---> a99051f28e6e
Successfully built a99051f28e6e
Successfully tagged deislabs/helloworld-cnab:43d45307a7e09da6d216da5cfce2a49d9af864fc
==> Successfully built bundle helloworld:0.1.0
➜  helloworld git:(master) ✗ ls
bundle.json cnab        duffle.json
➜  helloworld git:(master) ✗ duffle export ./
Error: Bundle manifest not found at /Users/jayunit100/go/src/github.com/deislabs/duffle/examples/helloworld/bundle.cnab
➜  helloworld git:(master) ✗ cat bundle.json

{
    "name": "helloworld",
    "version": "0.1.0",
    "invocationImages": {
        "cnab": {
            "name": "cnab",
            "builder": "docker",
            "configuration": {
                "registry": "deislabs"
            }
        }
    }
}
@bacongobbler
Copy link
Contributor

Because the helloworld example uses an unsigned bundle, you'll need to pass the --insecure flag to duffle export. Does that work?

@bacongobbler
Copy link
Contributor

alternatively, you can call duffle bundle sign -o bundle.cnab before calling duffle export to sign the bundle using your PGP key that was generated for you (see duffle key list).

@jayunit100
Copy link
Author

in general , there is no bundle.json , i just made one up.

Should there be one in this repository? I guess I'm confused about where duffle.json ends and bundle.json begins :).

@jayunit100
Copy link
Author

--insecure seems to get me further, but i think my hacked up bundle.json is incorrect... not sure wether i shoudl fix it , or wether we should just have a bundle.json in this repo for helloworld.

duffle export --insecure ./
Error: Error loading bundle: json: cannot unmarshal object into Go struct field Bundle.invocationImages of type []bundle.InvocationImage

@bacongobbler
Copy link
Contributor

Yeah, that error seems to indicate a malformed duffle.json. would you mind posting it here so we can see what's wrong?

@chris-crone
Copy link
Contributor

@jayunit100 Looking at your bundle.json, it's invalid as invocationImages is a map instead of a list.

You can try with something like this:

{
  "name": "helloworld",
  "version": "0.1.1",
  "description": "A short description of your bundle",
  "keywords": [
    "helloworld",
    "cnab",
    "tutorial"
  ],
  "maintainers": [
    {
      "name": "Jane Doe",
      "email": "jane.doe@example.com",
      "url": "https://example.com"
    }
  ],
  "invocationImages": [
    {
      "imageType": "docker",
      "image": "cnab/helloworld:0.1.1"
    }
  ],
  "images": null,
  "parameters": null,
  "credentials": null
}

I used the above bundle.json for an example of our CNAB to OCI repo.

@jayunit100
Copy link
Author

jayunit100 commented Jan 4, 2019

Cool ! It worked! . Can someone just PR that particular file into this repo , so that the example standsalone ... or is there a way to generate it ?

Since, bundle.json is required if you want to export an app, so I'd say its really a core requirement for any example CNAB app... Unless it can be generated automatically via duffle.

➜  helloworld git:(master) ✗ duffle export --insecure ./
➜  helloworld git:(master) ✗ ls
bundle.json          cnab                 duffle.json          helloworld-0.1.1.tgz

Great news is that the export works find for helloworld, for me, so I can begin building off of this.

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

No branches or pull requests

3 participants