chef-boneyard / knife-container

DEPRECATED: Container support for Chef's Knife Command
Apache License 2.0
57 stars 11 forks source link

support local (or explicitly specified) berkshelf configs #28

Closed bensonmiller closed 10 years ago

bensonmiller commented 10 years ago

When knife-container runs berks upload during the build phase (see the run_berks_upload method in container_docker_build.rb), berks will find the configuration file at ~/.berkshelf/config.json, but won't find local configuration files within a chef-repo. For example, when I run knife container docker build <params> within a chef-repo that contains a local config at chef-repo/.berkshelf/config.json, Berkshelf doesn't find it. The cause is that the CWD for the berks upload command has changed to the Docker context (chef-repo/dockerfiles/my_context) and berks doesn't do any recursive upward searching for .berkshelf directories to locate config files.

Some possible solutions:

  1. Add a new command-line option to explicitly identify a desired berks config.
  2. If the --berks option is true for knife container docker init . . . AND there is a .berkshelf/config.json in the CWD where you execute the init command, copy that config to dockerfiles/new_context/.berkshelf/config.json. With this solution, berks will pick up the local config automatically when executed from within the Docker context directory.
  3. If there is a .berkshelf/config.json in the CWD where you've run the build command, just tack-on the appropriate -c <file> command to berks upload. With this solution, users don't need to explicitly specify a berks config, but the configuration won't be added to the Docker context.

I like a combination of 1 and 2, but I need to see how things work when I add the berks configuration to the Docker context. I'll start working on this.

tduffield commented 10 years ago

I hesitate to put the config file in the image itself because 1) it is unnecessary to the image and 2) it is often unique to the user and thus would cause issues for shared contexts. I think the solution is to add an option to knife container docker build that would allow you to specify a path to a berks config.

bensonmiller commented 10 years ago

Sounds good.