Setup nginx for Cloud Run in a buildstep

cr_buildstep_nginx_setup(html_folder, ...)

Arguments

html_folder

The folder that will hold the HTML for Cloud Run

This uses a premade bash script that sets up a Docker container ready for Cloud Run running nginx

...

Other arguments passed to cr_buildstep_bash

See also

Examples

cr_project_set("my-project")
#> 2020-09-18 14:21:55 > ProjectId set to my-project
#> [1] "my-project"
cr_bucket_set("my-bucket")
#> 2020-09-18 14:21:55 > Bucket set to my-bucket
#> [1] "my-bucket"
cr_region_set("europe-west1")
#> 2020-09-18 14:21:55 > Region set to europe-west1
#> [1] "europe-west1"
html_folder <- "my_html" run_image <- "gcr.io/my-project/my-image-for-cloudrun" cr_build_yaml( steps = c( cr_buildstep_nginx_setup(html_folder), cr_buildstep_docker(run_image, dir = html_folder), cr_buildstep_run(name = "running-nginx", image = run_image, concurrency = 80) ) )
#> ==cloudRunnerYaml== #> steps: #> - name: ubuntu #> args: #> - bash #> - -c #> - |- #> echo " #> server { #> listen \$${PORT}; #> server_name localhost; #> location / { #> root /usr/share/nginx/html; #> index index.html index.htm; #> } #> }" > default.template #> #> cat <<EOF >Dockerfile #> FROM nginx #> COPY . /usr/share/nginx/html #> COPY default.template /etc/nginx/conf.d/default.template #> CMD envsubst < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;' #> EOF #> #> cat default.template #> cat Dockerfile #> id: setup nginx #> dir: my_html #> - name: gcr.io/cloud-builders/docker #> args: #> - build #> - -f #> - Dockerfile #> - --tag #> - gcr.io/my-project/my-image-for-cloudrun:latest #> - --tag #> - gcr.io/my-project/my-image-for-cloudrun:$BUILD_ID #> - '.' #> dir: my_html #> - name: gcr.io/cloud-builders/docker #> args: #> - push #> - gcr.io/my-project/my-image-for-cloudrun #> dir: my_html #> - name: gcr.io/cloud-builders/gcloud #> args: #> - beta #> - run #> - deploy #> - running-nginx #> - --image #> - gcr.io/my-project/my-image-for-cloudrun #> - --region #> - europe-west1 #> - --platform #> - managed #> - --concurrency #> - '80' #> - --port #> - default #> - --max-instances #> - default #> - --memory #> - 256Mi #> - --cpu #> - '1' #> - --clear-env-vars #> - --allow-unauthenticated #> id: deploy cloudrun #> - name: gcr.io/cloud-builders/gcloud #> args: #> - run #> - services #> - add-iam-policy-binding #> - --region #> - europe-west1 #> - --member=allUsers #> - --role=roles/run.invoker #> - --platform #> - managed #> - running-nginx #> id: auth cloudrun