Skip to content

Commit

Permalink
Merge branch 'add_support_for_build_context' into 'master'
Browse files Browse the repository at this point in the history
Add support for defining a custom build_context when devlab is building images

See merge request evernym/utilities/devlab!21
  • Loading branch information
absltkaos committed Jun 9, 2023
2 parents 44bb642 + 9773b34 commit 2493a6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ The structure looks like this:
{
"tag": ""|[],
"docker_file": "",
"build_context": "",
"build_opts": [],
"skip_pull": BOOL,
"ordinal": {
Expand All @@ -253,7 +254,8 @@ All Keys that are in **bold** are required
| Key | Type | Value Description |
| --- | --- | --- |
| **tag** | String or List of Strings | This is a tag that should be applied to the image. If a list is passed, the first tag becomes a primary identifier. |
| **docker_file** | String | Path to the docker file, relative to the project's root to use when building the image. ***[NOTE]*** The build context will be the parent directory of the dockerfile's path |
| **docker_file** | String | Path to the docker file, relative to the project's root to use when building the image. ***[NOTE]*** If `build_context` is NOT set then the build context will be the parent directory of the dockerfile's path |
| build_context | String | Path (relative to the project) for the docker build command to run. This sets the docker build context, so will affect COPY commands in dockerfiles etc... Remember that this path and all files have to be copied/sent to the docker daemon, so be careful of the size of the directory you set here |
| build_opts | List of Strings | Additional options to pass to the `docker build` command. Each CLI arg must be it's own element. For example: `[ '--build-arg', 'foo=bar' ]` would become `docker build --build-arg foo=bar PATH...` etc... |
| skip_pull | Boolean | Whether or not a forced pull does anything. There are cases where an image is built locally used elsewhere, so a pull will fail since it isn't on docker hub. If this is `true`, then even when a build is requesting a `pull` it will skip it for this image |
| ordinal | Hash | This is used indicate the order of the images to build. When parallel execution is supported, the `group` key indicates the image that can be built at the same time, `number` indicates the order inside the group to start up |
Expand Down
5 changes: 4 additions & 1 deletion devlab_bench/actions/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def action(images='*', clean=False, no_cache=False, pull=False, skip_pull_images
else:
image_n_tag = '{}:{}'.format(image, images_dict[image]['tag'])
image_status = docker_obj_status(image_n_tag, 'image', devlab_bench.helpers.docker.DOCKER, logger=log)[0]
image_context = os.path.dirname('{}/{}'.format(devlab_bench.PROJ_ROOT, images_dict[image]['docker_file']))
image_context = images_dict[image].get(
'build_context',
os.path.dirname('{}/{}'.format(devlab_bench.PROJ_ROOT, images_dict[image]['docker_file']))
)
docker_helper_obj = docker_helper
build_context = devlab_bench.PROJ_ROOT
if image in base_images_to_build: #Override default build context for built-in images
Expand Down

0 comments on commit 2493a6a

Please sign in to comment.