Skip to content

Commit

Permalink
feat: configurable kaniko based cloud builds (#107)
Browse files Browse the repository at this point in the history
* feat: configurable kaniko based cloud builds
  • Loading branch information
jsilva authored Mar 11, 2024
1 parent 51797f1 commit 605b03a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/wanna/core/models/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class DockerModel(BaseModel, extra=Extra.forbid, validate_assignment=True):
- `cloud_build_workerpool` - [str] (optional) Name of the GCP Cloud Build workerpool if you want to use one
- `cloud_build_workerpool_location` - [str] (optional) Location of the GCP Cloud Build workerpool. Must be specified
if cloud_build_workerpool is set.
- `cloud_build_kaniko_version` - [str] (optional) which https://github.com/GoogleContainerTools/kaniko/ version to use
- `cloud_build_kaniko_flags` - [str] (optional) which https://github.com/GoogleContainerTools/kaniko/ flags to use
"""

images: List[DockerImageModel] = []
Expand All @@ -102,6 +104,12 @@ class DockerModel(BaseModel, extra=Extra.forbid, validate_assignment=True):
cloud_build: bool = False
cloud_build_workerpool: Optional[str]
cloud_build_workerpool_location: Optional[str]
cloud_build_kaniko_version: Optional[str] = "latest"
cloud_build_kaniko_flags: List[str] = [
"--cache=true",
"--compressed-caching=false",
"--cache-copy-layers=true",
]


class DockerBuildResult(BaseModel, extra=Extra.forbid):
Expand Down
7 changes: 5 additions & 2 deletions src/wanna/core/services/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(
wanna_project_name: str,
quick_mode: bool = False, # just returns tags but does not build
):
self.docker_model = docker_model
self.image_models = docker_model.images
self.image_store: Dict[str, Tuple[DockerImageModel, Optional[Image], str]] = {}

Expand Down Expand Up @@ -376,8 +377,10 @@ def _build_image_on_gcp_cloud_build(
tags_args = " ".join([f"--destination={t}" for t in tags]).split()

steps = BuildStep(
name="gcr.io/kaniko-project/executor:latest",
args=tags_args + ["--cache=true", "--dockerfile", dockerfile],
name=f"gcr.io/kaniko-project/executor:{self.docker_model.cloud_build_kaniko_version}",
args=tags_args
+ self.docker_model.cloud_build_kaniko_flags
+ ["--dockerfile", dockerfile],
)

timeout = Duration()
Expand Down

0 comments on commit 605b03a

Please sign in to comment.