Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

Local dependencies #227

Open
nhumrich opened this issue Jun 27, 2016 · 4 comments
Open

Local dependencies #227

nhumrich opened this issue Jun 27, 2016 · 4 comments

Comments

@nhumrich
Copy link

Does acbuild support local dependencies?
I am trying to build two containers, one on top of the other, and would like to do it locally without having to host the image somewhere.
Here is what I am trying

#!/usr/bin/env bash
set -e
acbuild --debug begin

acbuild --debug set-name my-base
# build from local aci
acbuild --debug dep add base.aci

acbuild --debug run ls
acbuild --debug write --overwrite my-image.aci
acbuild end

But I get a discovery failed message:

Beginning build with an empty ACI
Setting name of ACI to my-base
Adding dependency "base.aci"
Running: [ls]
run: discovery failed

How would I do this locally?

@cgonyeo
Copy link
Member

cgonyeo commented Jun 27, 2016

Right now, acbuild doesn't support local dependencies. Once #222 gets merged it should be trivial to add though, so I'm hoping that the next release of acbuild will support what you want.

As a temporary workaround there are two things you can do to get what you want, one's hacky and the other changes the semantics of your script, and neither are great.

The hacky solution:

When acbuild performs a run command it fetches and renders locally the dependencies it's missing. This process amounts to the following:

  • performing discovery
  • downloading the image
  • decompressing it
  • placing it at .acbuild/depstore-tar/sha512-<hash>
  • untarring the file to .acbuild/depstore-expanded/sha512-<hash>
  • creating the file acbuild/depstore-expanded/sha512-<hash>/rendered

If you perform the rendering step yourself, acbuild will use the dependency from its local store instead of trying to fetch it. These are the steps to do this, assuming myapp.aci is the dependency in your current directory:

  • gunzip -S myapp.aci
  • sha512sum myapp. and note the hash that this command outputs
  • mkdir -p .acbuild/depstore-tar .acbuild/depstore-expanded
  • mv myapp. .acbuild/depstore-tar/sha512-<hash>
  • mkdir .acbuild/depstore-expanded/sha512-<hash>
  • tar xfv .acbuild/depstore-tar/sha512-<hash> -C .acbuild/depstore-expanded/sha512-<hash>
  • touch .acbuild/depstore-expanded/sha512-<hash>/rendered

This will need to be done after you've called acbuild begin and before you've called acbuild run.

The less hacky solution:

A much simpler workaround is to simply start the second build on top of your dependency, so

acbuild begin ./myapp.aci

This will produce a different image from what you were originally going for though, as instead of having a dependency on the first image your second image will include all of the files from the first image, and the manifest at the beginning of the build will not be empty but will instead contain the contents of the first image's manifest.

@doublec
Copy link

doublec commented Jan 17, 2017

Are the steps above for manually unpacking the local aci still expected to work? I tried:

acbuild begin
...follow steps above to unpack a linux image aci...
acbuild run -- ls
run: ls not found in any of: [/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin]

This works however:

acbuild begin ./foo.aci
acbuild run -- ls
...command runs...

Is there an additional step needed?

Edit: Oops, solved it, I missed out the "acbuild dep add [name of local aci]" step. Sorry!

@cgonyeo
Copy link
Member

cgonyeo commented Jan 17, 2017

No worries! Also if you're going to be making any scripts based on this completely unsupported workaround, just a heads up that the path .acbuild/currentaci is going to change to .acbuild/current in the next release due to #276

@sanmai-NL
Copy link
Contributor

Seems this one can be closed, esp. once #316 is merged.

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

4 participants