Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable kaniko based cloud builds #107

Merged
merged 5 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading