Skip to content

Commit 03c9ee5

Browse files
authored
Update region tags (GoogleCloudPlatform#4951)
1 parent 721c089 commit 03c9ee5

File tree

15 files changed

+126
-83
lines changed

15 files changed

+126
-83
lines changed

run/hello-broken/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_broken_dockerfile]
1516
# [START run_broken_dockerfile]
1617

1718
# Use the official Python image.
@@ -33,10 +34,11 @@ ENV APP_HOME /app
3334
WORKDIR $APP_HOME
3435
COPY . ./
3536

36-
# Run the web service on container startup.
37+
# Run the web service on container startup.
3738
# Use gunicorn webserver with one worker process and 8 threads.
3839
# For environments with multiple CPU cores, increase the number of workers
3940
# to be equal to the cores available.
4041
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app
4142

4243
# [END run_broken_dockerfile]
44+
# [END cloudrun_broken_dockerfile]

run/hello-broken/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_broken_service]
1516
# [START run_broken_service]
1617
import json
1718
import os
@@ -26,22 +27,26 @@
2627
def index():
2728
print("hello: received request.")
2829

30+
# [START cloudrun_broken_service_problem]
2931
# [START run_broken_service_problem]
3032
NAME = os.getenv("NAME")
3133

3234
if not NAME:
3335
print("Environment validation failed.")
3436
raise Exception("Missing required service parameter.")
3537
# [END run_broken_service_problem]
38+
# [END cloudrun_broken_service_problem]
3639

3740
return f"Hello {NAME}"
3841
# [END run_broken_service]
42+
# [END cloudrun_broken_service]
3943

4044

4145
@app.route("/improved", methods=["GET"])
4246
def improved():
4347
print("hello: received request.")
4448

49+
# [START cloudrun_broken_service_upgrade]
4550
# [START run_broken_service_upgrade]
4651
NAME = os.getenv("NAME")
4752

@@ -53,10 +58,12 @@ def improved():
5358
}
5459
print(json.dumps(error_message))
5560
# [END run_broken_service_upgrade]
61+
# [END cloudrun_broken_service_upgrade]
5662

5763
return f"Hello {NAME}"
5864

5965

66+
# [START cloudrun_broken_service]
6067
# [START run_broken_service]
6168
if __name__ == "__main__":
6269
PORT = int(os.getenv("PORT")) if os.getenv("PORT") else 8080
@@ -65,3 +72,4 @@ def improved():
6572
# application on Cloud Run. See entrypoint in Dockerfile.
6673
app.run(host="127.0.0.1", port=PORT, debug=True)
6774
# [END run_broken_service]
75+
# [END cloudrun_broken_service]

run/helloworld/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_helloworld_dockerfile]
1516
# [START run_helloworld_dockerfile]
1617

1718
# Use the official lightweight Python image.
@@ -36,3 +37,4 @@ RUN pip install Flask gunicorn
3637
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app
3738

3839
# [END run_helloworld_dockerfile]
40+
# [END cloudrun_helloworld_dockerfile]

run/helloworld/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_helloworld_service]
1516
# [START run_helloworld_service]
1617
import os
1718

@@ -29,3 +30,4 @@ def hello_world():
2930
if __name__ == "__main__":
3031
app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))
3132
# [END run_helloworld_service]
33+
# [END cloudrun_helloworld_service]

run/image-processing/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ COPY requirements.txt ./
2626
# Install production dependencies.
2727
RUN pip install -r requirements.txt
2828

29+
# [START cloudrun_imageproc_dockerfile_imagemagick]
2930
# [START run_imageproc_dockerfile_imagemagick]
3031
# Install Imagemagick into the container image.
3132
# For more on system packages review the system packages tutorial.
@@ -35,14 +36,15 @@ RUN set -ex; \
3536
apt-get -y install imagemagick; \
3637
rm -rf /var/lib/apt/lists/*
3738
# [END run_imageproc_dockerfile_imagemagick]
39+
# [END cloudrun_imageproc_dockerfile_imagemagick]
3840

3941
# Copy local code to the container image.
4042
ENV APP_HOME /app
4143
WORKDIR $APP_HOME
4244
COPY . ./
4345

44-
# Run the web service on container startup.
46+
# Run the web service on container startup.
4547
# Use gunicorn webserver with one worker process and 8 threads.
4648
# For environments with multiple CPU cores, increase the number of workers
4749
# to be equal to the cores available.
48-
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app
50+
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app

run/image-processing/image.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
15+
# [START cloudrun_imageproc_handler_setup]
1616
# [START run_imageproc_handler_setup]
1717
import os
1818
import tempfile
@@ -23,8 +23,10 @@
2323
storage_client = storage.Client()
2424
vision_client = vision.ImageAnnotatorClient()
2525
# [END run_imageproc_handler_setup]
26+
# [END cloudrun_imageproc_handler_setup]
2627

2728

29+
# [START cloudrun_imageproc_handler_analyze]
2830
# [START run_imageproc_handler_analyze]
2931
# Blurs uploaded images that are flagged as Adult or Violence.
3032
def blur_offensive_images(data):
@@ -56,8 +58,10 @@ def blur_offensive_images(data):
5658

5759

5860
# [END run_imageproc_handler_analyze]
61+
# [END cloudrun_imageproc_handler_analyze]
5962

6063

64+
# [START cloudrun_imageproc_handler_blur]
6165
# [START run_imageproc_handler_blur]
6266
# Blurs the given file using ImageMagick.
6367
def __blur_image(current_blob):
@@ -89,3 +93,4 @@ def __blur_image(current_blob):
8993

9094

9195
# [END run_imageproc_handler_blur]
96+
# [END cloudrun_imageproc_handler_blur]

run/image-processing/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_imageproc_controller]
1516
# [START run_imageproc_controller]
1617
import base64
1718
import json
@@ -69,6 +70,7 @@ def index():
6970

7071
return ('', 500)
7172
# [END run_imageproc_controller]
73+
# [END cloudrun_imageproc_controller]
7274

7375

7476
if __name__ == '__main__':

run/logging-manual/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
def index():
2626
PROJECT = os.environ['GOOGLE_CLOUD_PROJECT']
2727

28+
# [START cloudrun_manual_logging]
2829
# [START run_manual_logging]
2930
# Uncomment and populate this variable in your code:
3031
# PROJECT = 'The project ID of your Cloud Run service';
@@ -50,6 +51,7 @@ def index():
5051

5152
print(json.dumps(entry))
5253
# [END run_manual_logging]
54+
# [END cloudrun_manual_logging]
5355

5456
return 'Hello Logger!'
5557

run/markdown-preview/editor/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def index():
2929
return render_template("index.html", default=f.read())
3030

3131

32+
# [START cloudrun_secure_request_do]
3233
# [START run_secure_request_do]
3334
@app.route("/render", methods=["POST"])
3435
def render_handler():
@@ -40,6 +41,7 @@ def render_handler():
4041
parsed_markdown = render.new_request(data)
4142
return parsed_markdown
4243
# [END run_secure_request_do]
44+
# [END cloudrun_secure_request_do]
4345

4446

4547
if __name__ == "__main__":

run/markdown-preview/editor/render.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# [START cloudrun_secure_request]
1516
# [START run_secure_request]
1617
import os
1718
import urllib
@@ -43,3 +44,4 @@ def new_request(data):
4344
response = urllib.request.urlopen(req)
4445
return response.read()
4546
# [END run_secure_request]
47+
# [END cloudrun_secure_request]

0 commit comments

Comments
 (0)