Execute Docker Compose builds.
(obj, image, *, force_pull, use_cache, use_leaf_cache)
| 143 | "image and its ancestors use --no-cache option.") |
| 144 | @click.pass_obj |
| 145 | def docker_build(obj, image, *, force_pull, use_cache, use_leaf_cache): |
| 146 | """ |
| 147 | Execute Docker Compose builds. |
| 148 | """ |
| 149 | compose = obj['compose'] |
| 150 | |
| 151 | try: |
| 152 | if force_pull: |
| 153 | compose.pull(image, pull_leaf=use_leaf_cache) |
| 154 | compose.build(image, use_cache=use_cache, |
| 155 | use_leaf_cache=use_leaf_cache, |
| 156 | pull_parents=force_pull) |
| 157 | except UndefinedImage as e: |
| 158 | raise click.ClickException( |
| 159 | "There is no service/image defined in compose.yaml with " |
| 160 | f"name: {e}" |
| 161 | ) |
| 162 | except RuntimeError as e: |
| 163 | raise click.ClickException(str(e)) |
| 164 | |
| 165 | |
| 166 | @docker.command('run') |