Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6.7k
Add new django tutorial#4869
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
Uh oh!
There was an error while loading. Please reload this page.
Add new django tutorial #4869
Changes from all commits
ff73fcab5ccc3c6ea8b1b1ba9285e6c93627cd94bb01fbedf711a50fb01118d97088bda3960e8c0a4753e75ee5955db6c4b0d3e61b39521ba0c90a479a0c1160f54fd083145a0508de34ae043e0fea1a459a690a3297a1343311df192547a4d8ec6f9fb3094885d44fb56ecdf3897bada453f027981375756daf986573fe9a94cb26426d018fa8c19be5911acb5992e8c643d498837e15e1cb0a0308d64911ca50877c658700a2cd466a801c1887334d33c68344f35e3ed2a6e8fa7cc38f854e91809ab5cefb39a2b61310cd0b8d19492d672601b222ca3427f1b79c2e9cbe76e8556fc738a9b5e62e4d3e51cd2b7837611460b5ff6fce68c2b09698cb5ea1e9877d7004c0900895f8fb05aa42c1db86b5d8a557f87ebb84adc6fda4a956fb9a48ab46d544f27986d667ffff2dd529d19e6caaf71edf555d95a6989bf42d428b12a0c55cdeac7034b114371a4e31e692e4dd31f8712b3feeca3c2652d5ee08d2961e441b59763ad5b82df36f5395697620b626e1d465c4f1063a0d7874880c66ab2fd21a4a18d3fe5e78fdb21095426f9c0ff7dd205260699a9257409683fc6b2File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -15,6 +15,7 @@ This directory contains samples for [Google Cloud Run](https://cloud.run). [Clou | ||
| |[Cloud Pub/Sub][pubsub] | Handling Pub/Sub push messages | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30">][run_button_pubsub] | | ||
| |[Cloud SQL (MySQL)][mysql] | Use MySQL with Cloud Run | - | | ||
| |[Cloud SQL (Postgres)][postgres] | Use Postgres with Cloud Run | - | | ||
| |[Django][django] | Deploy Django on Cloud Run | - | | ||
glasnt marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| For more Cloud Run samples beyond Python, see the main list in the [Cloud Run Samples repository](https://github.com/GoogleCloudPlatform/cloud-run-samples). | ||
| @@ -109,6 +110,7 @@ for more information. | ||
| [pubsub]: pubsub/ | ||
| [mysql]: ../cloud-sql/mysql/sqlalchemy | ||
| [postgres]: ../cloud-sql/postgres/sqlalchemy | ||
| [django]: django/ | ||
| [run_button_helloworld]: https://deploy.cloud.run/?git_repo=https://github.com/knative/docs&dir=docs/serving/samples/hello-world/helloworld-python | ||
| [run_button_pubsub]: https://deploy.cloud.run/?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&dir=run/pubsub | ||
| [testing]: https://cloud.google.com/run/docs/testing/local#running_locally_using_docker_with_access_to_services | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .env |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Copyright 2020 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # Use an official lightweight Python image. | ||
glasnt marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # https://hub.docker.com/_/python | ||
| FROM python:3.8-slim | ||
| ENV APP_HOME /app | ||
| WORKDIR $APP_HOME | ||
| # Removes output stream buffering, allowing for more efficient logging | ||
| ENV PYTHONUNBUFFERED 1 | ||
| # Install dependencies | ||
| COPY requirements.txt . | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
| # Copy local code to the container image. | ||
| COPY . . | ||
| # Run the web service on container startup. Here we use the gunicorn | ||
| # webserver, with one worker process and 8 threads. | ||
| # For environments with multiple CPU cores, increase the number of workers | ||
| # to be equal to the cores available. | ||
| CMD exec gunicorn --bind 0.0.0.0:$PORT --workers 1 --threads 8 --timeout 0 mysite.wsgi:application | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Getting started with Django on Cloud Run | ||
| [![Open in Cloud Shell][shell_img]][shell_link] | ||
averikitsch marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| [shell_img]: http://gstatic.com/cloudssh/images/open-btn.png | ||
| [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=run/django/README.md | ||
| This repository is an example of how to run a [Django](https://www.djangoproject.com/) | ||
| app on Google Cloud Run (fully managed). | ||
| The Django application used in this tutorial is the [Writing your first Django app](https://docs.djangoproject.com/en/3.0/#first-steps), after completing [Part 1](https://docs.djangoproject.com/en/3.0/intro/tutorial01/) and [Part 2](https://docs.djangoproject.com/en/3.0/intro/tutorial02/). | ||
| # Tutorial | ||
| See our [Running Django on Cloud Run (fully managed)](https://cloud.google.com/python/django/run) tutorial for instructions for setting up and deploying this sample application. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Copyright 2020 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| steps: | ||
| - id: "build image" | ||
| name: "gcr.io/cloud-builders/docker" | ||
| args: ["build", "-t", "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}", "."] | ||
| - id: "push image" | ||
| name: "gcr.io/cloud-builders/docker" | ||
| args: ["push", "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}"] | ||
| - id: "apply migrations" | ||
| name: "gcr.io/google-appengine/exec-wrapper" | ||
| args: | ||
| [ | ||
| "-i", | ||
| "gcr.io/$PROJECT_ID/${_SERVICE_NAME}", | ||
| "-s", | ||
| "${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}", | ||
| "-e", | ||
| "SETTINGS_NAME=${_SECRET_SETTINGS_NAME}", | ||
| "--", | ||
| "python", | ||
| "manage.py", | ||
| "migrate", | ||
| ] | ||
| - id: "collect static" | ||
| name: "gcr.io/google-appengine/exec-wrapper" | ||
| args: | ||
| [ | ||
| "-i", | ||
| "gcr.io/$PROJECT_ID/${_SERVICE_NAME}", | ||
| "-s", | ||
| "${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}", | ||
| "-e", | ||
| "SETTINGS_NAME=${_SECRET_SETTINGS_NAME}", | ||
| "--", | ||
| "python", | ||
| "manage.py", | ||
| "collectstatic", | ||
| "--no-input", | ||
| ] | ||
| substitutions: | ||
| _INSTANCE_NAME: django-instance | ||
| _REGION: us-central1 | ||
| _SERVICE_NAME: polls-service | ||
| _SECRET_SETTINGS_NAME: django-settings | ||
| images: | ||
| - "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}" |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.