-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add new django tutorial #4869
Changes from 18 commits
ff73fca
b5ccc3c
6ea8b1b
1ba9285
e6c9362
7cd94bb
01fbedf
711a50f
b01118d
97088bd
a3960e8
c0a4753
e75ee59
55db6c4
b0d3e61
b39521b
a0c90a4
79a0c11
60f54fd
083145a
0508de3
4ae043e
0fea1a4
59a690a
3297a13
43311df
192547a
4d8ec6f
9fb3094
885d44f
b56ecdf
3897bad
a453f02
7981375
756daf9
86573fe
9a94cb2
6426d01
8fa8c19
be5911a
cb5992e
8c643d4
98837e1
5e1cb0a
0308d64
911ca50
877c658
700a2cd
466a801
c188733
4d33c68
344f35e
3ed2a6e
8fa7cc3
8f854e9
1809ab5
cefb39a
2b61310
cd0b8d1
9492d67
2601b22
2ca3427
f1b79c2
e9cbe76
e8556fc
738a9b5
e62e4d3
e51cd2b
7837611
460b5ff
6fce68c
2b09698
cb5ea1e
9877d70
04c0900
895f8fb
05aa42c
1db86b5
d8a557f
87ebb84
adc6fda
4a956fb
9a48ab4
6d544f2
7986d66
7ffff2d
d529d19
e6caaf7
1edf555
d95a698
9bf42d4
28b12a0
c55cdea
c7034b1
14371a4
e31e692
e4dd31f
8712b3f
eeca3c2
652d5ee
08d2961
e441b59
763ad5b
82df36f
5395697
620b626
e1d465c
4f1063a
0d78748
80c66ab
2fd21a4
a18d3fe
5e78fdb
2109542
6f9c0ff
7dd2052
60699a9
2574096
83fc6b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud Platform | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
# | ||
# For more information, run: | ||
# $ gcloud topic gcloudignore | ||
# | ||
.gcloudignore | ||
# If you would like to upload your .git directory, .gitignore file or files | ||
# from your .gitignore file, remove the corresponding line | ||
# below: | ||
.git | ||
.gitignore | ||
|
||
# Python pycache: | ||
__pycache__/ | ||
|
||
venv/ | ||
.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Use an official lightweight Python image. | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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 -r requirements.txt | ||
|
||
# Copy local code to the container image. | ||
COPY . . | ||
|
||
# Service must listen to $PORT environment variable. | ||
# This default value facilitates local development. | ||
ENV PORT 8080 | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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,25 @@ | ||
# Getting started with Django on Google Cloud Platform on Cloud Run (fully managed) | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[![Open in Cloud Shell][shell_img]][shell_link] | ||
averikitsch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[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/)). | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we 100% sure that Google authored this code and we're able to claim it under this repo's license? It seems like this tutorial should be hosted on Django's website/repo and not here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed the pattern from the kubernetes and appengine samples. |
||
|
||
|
||
# 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. | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
## Contributing changes | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* See [CONTRIBUTING.md](CONTRIBUTING.md) | ||
|
||
|
||
## Licensing | ||
|
||
* See [LICENSE](LICENSE) | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
steps: | ||
|
||
# Build the image | ||
- name: "gcr.io/cloud-builders/docker" | ||
args: ["build", "-t", "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}", "."] | ||
|
||
# Push the image to the Container Registry | ||
- name: "gcr.io/cloud-builders/docker" | ||
args: ["push", "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}"] | ||
|
||
# Apply the Django database migration against the Cloud SQL database | ||
- name: "gcr.io/google-appengine/exec-wrapper" | ||
args: ["-i", "gcr.io/$PROJECT_ID/${_SERVICE_NAME}", | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"-s", "${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}", | ||
"--", "python", "manage.py", "migrate"] | ||
|
||
# Apply the static migrations against the Cloud Storage bucket | ||
- name: "gcr.io/google-appengine/exec-wrapper" | ||
args: ["-i", "gcr.io/$PROJECT_ID/${_SERVICE_NAME}", | ||
"-s", "${PROJECT_ID}:${_REGION}:${_INSTANCE_NAME}", | ||
"--", "python", "manage.py", "collectstatic", "--no-input"] | ||
|
||
substitutions: | ||
_INSTANCE_NAME: django-instance | ||
_REGION: us-central1 | ||
_SERVICE_NAME: polls-service | ||
|
||
images: | ||
- "gcr.io/${PROJECT_ID}/${_SERVICE_NAME}" |
Uh oh!
There was an error while loading. Please reload this page.