This helps the common use case of building a Dockerfile based on the contents of a GitHub repo, and sets up a build trigger so it will build on every commit.

cr_deploy_docker_trigger(
  repo,
  image,
  trigger_name = paste0("docker-", image),
  image_tag = c("latest", "$SHORT_SHA", "$BRANCH_NAME"),
  ...,
  substitutions = NULL,
  ignoredFiles = NULL,
  includedFiles = NULL,
  timeout = NULL,
  projectId_target = cr_project_get()
)

Arguments

repo

The git repo holding the Dockerfile from cr_buildtrigger_repo

image

The name of the image you want to build

trigger_name

The trigger name

image_tag

What to tag the build docker image

...

Arguments passed on to cr_buildstep_docker

tag

The tag or tags to be attached to the pushed image - can use Build macros

location

Where the Dockerfile to build is in relation to dir

projectId

The projectId

dockerfile

Specify the name of the Dockerfile found at location

kaniko_cache

If TRUE will use kaniko cache for Docker builds.

build_args

additional arguments to pass to docker build, should be a character vector.

push_image

if kaniko_cache = FALSE and push_image = FALSE, then the docker image is simply built and not pushed

substitutions

A named list of Build macro variables

ignoredFiles

ignored_files and included_files are file glob matches extended with support for "**".

includedFiles

If any of the files altered in the commit pass the ignored_files

timeout

Timeout for build

projectId_target

The project to publish the Docker image to. The image will be built under the project configured via cr_project_get. You will need to give the build project's service email access to the target GCP project via IAM for it to push successfully.

Details

This creates a buildtrigger to do a kamiko cache enabled Docker build upon each commit, as defined by your repo settings via cr_buildtrigger_repo. It will build all tags concurrently.

See also

cr_deploy_docker which lets you build Dockerfiles for more generic use cases

Other Deployment functions: cr_deploy_docker(), cr_deploy_packagetests(), cr_deploy_pkgdown(), cr_deploy_run_website(), cr_deploy_run(), cr_deploy_r()

Examples

if (FALSE) {
repo <- cr_buildtrigger_repo("MarkEdmondson1234/googleCloudRunner")
# create trigger that will publish Docker image to gcr.io/your-project/test upon each GitHub commit
cr_deploy_docker_trigger(repo, "test", dir = "cloud_build")

# build in one project, publish the docker image to another project (gcr.io/another-project/test)
cr_deploy_docker_trigger(repo, "test", projectId_target = "another-project", dir = "cloud_build")
}