Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
28 changes: 26 additions & 2 deletions docs/source/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ This can be done by running:

Here the service account from `project_b` is granted permissions to read from artifact registry en `project_a`

For adding custom tags to be created in cloud build and pushed to artifact registry, use the `GOBLET_BUILD_TAGS` environment variable with a comma-sepparated list of tags to be created:
For adding custom tags to be created in cloud build and pushed to artifact registry, use the `GOBLET_BUILD_TAGS` environment variable with a comma-sepparated list of tags to be created:

.. code:: bash

GOBLET_BUILD_TAGS=tag1,tag2,tag3

To use a previously built artifact, use the `artifact_tag` configuration in the `deploy` configuration key or use the `GOBLET_ARTIFACT_TAG` environment variable. When using `artifact_tag`, source code will not be uploaded and cloudbuild will not be called. `artifact_tag` can be any existing tag or digest in the default registry or the configured `artifact_registry`.
To use a previously built artifact, use the `artifact_tag` configuration in the `deploy` configuration key or use the `GOBLET_ARTIFACT_TAG` environment variable. When using `artifact_tag`, source code will not be uploaded and cloudbuild will not be called. `artifact_tag` can be any existing tag or digest in the default registry or the configured `artifact_registry`.

.. code:: json

{
Expand All @@ -149,3 +151,25 @@ To use a previously built artifact, use the `artifact_tag` configuration in the
GOBLET_ARTIFACT_TAG=tag1
# or
GOBLET_ARTIFACT_TAG=sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef


To pass `Build Arg <https://docs.docker.com/build/guide/build-args>`__ to `docker build` during CloudBuild , use the environment variable `GOBLET_BUILD_ARGS`.

For example, to set the `FROM` image tag in the Dockerfile



`Dockefile`

.. code:: Dockerfile

ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-slim

# dockerfile instrutions...

`Goblet Deploy`

.. code:: bash

$ GOBLET_BUILD_ARGS=PYTHON_VERSION=3.10.8 goblet deploy ...
12 changes: 11 additions & 1 deletion goblet/backends/cloudrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ def _checksum(self):

def _get_cloudbuild_steps(self, images):
cloudbuild_cache = self.config.deploy.get("cloudbuild_cache", "DOCKER_LATEST")

build_args = os.environ.get("GOBLET_BUILD_ARGS", [])
if build_args:
build_args = build_args.split(",")

if cloudbuild_cache == "DOCKER_LATEST":
steps = [
{
Expand All @@ -253,6 +258,9 @@ def _get_cloudbuild_steps(self, images):
"--network=cloudbuild",
]
+ list(map(lambda image: ["-t", image], images))
+ list(
map(lambda build_arg: ["--build-arg", build_arg], build_args)
)
+ [
"--cache-from",
images[0],
Expand All @@ -268,7 +276,8 @@ def _get_cloudbuild_steps(self, images):
f"--destination={images[0]}",
"--cache=true",
f"--cache-ttl={24*365*3}h",
],
]
+ [["--build-arg", f"{build_arg}"] for build_arg in build_args],
},
{
"name": "gcr.io/cloud-builders/docker",
Expand All @@ -286,6 +295,7 @@ def _get_cloudbuild_steps(self, images):
],
},
]

else:
raise Exception(f"Invalid cloudbuild_cache option {cloudbuild_cache}")

Expand Down
Loading