You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Build an serverless end-to-end photo sharing application with Google Cloud
2
2
3
-
This repo will help you create an end-to-end social media web app with Google Cloud and Terraform
3
+
This deploystack will help you create a scalable end-to-end photo-sharing application with 11 Google Cloud, Terraform, and Django.
4
+
5
+
## Architecture
6
+
4
7

5
8
6
-
Components created:
7
-
* Cloud Run - which will run the app as the main server
8
-
* Cloud SQL - To store relational database such as user info, posts
9
-
* Cloud Storage - To store non-relational database such as post media
10
-
* Cloud Load Balancer - To server traffic with multiple regions
11
-
* Cloud DNS - To map custom domain
12
-
* Cloud Build - To automatically deploy your app from gcloud
13
-
* Secret Manager - To improve the security of the app
14
-
* Cloud VPC - To connect Cloud SQL with Cloud Run via Private improve
15
-
* Cloud DNS - to store static cache for faster connections
16
-
* Translation API - to translate the post caption if it is in another language
17
-
18
-
What you can do with this app:
9
+
**Components created:**
10
+
* Cloud Run - which will run the app as the main server.
11
+
* Cloud SQL - To store relational database such as user info, posts.
12
+
* Cloud Storage - To store non-relational database such as post media.
13
+
* Cloud Load Balancer - To server traffic with multiple regions.
14
+
* Cloud DNS - To map custom domain and handle requests from your local machines everytime you go to the url.
15
+
* Cloud Build - apply DevOps CI/CD to automatically deploy your app from gcloud.
16
+
* Secret Manager - To improve the security of the app.
17
+
* Cloud VPC - To connect Cloud SQL with Cloud Run via private network.
18
+
* Cloud DNS - to store static cache for faster connections.
19
+
* Translation API - to translate the post caption if it is in another language.
20
+
* Container Registry - to store, manage, and secure your Docker container images.
21
+
22
+
**What you can do with this app:**
19
23
* Create post with media and caption
20
24
* Search users
21
25
* View newsfeed
@@ -40,14 +44,14 @@ To remove all billing components from the project
40
44
2. Typing `deploystack uninstall`
41
45
42
46
## How to run
43
-
1. Create project with billing enabled, and configure gcloud for that project
47
+
**1. Create project with billing enabled, and configure gcloud for that project**
44
48
45
49
```
46
50
export PROJECT_ID=foobar
47
51
gcloud config set project $PROJECT_ID
48
52
```
49
53
50
-
2. Configure default credentials (allows Terraform to apply changes):
54
+
**2. Configure default credentials (allows Terraform to apply changes):**
51
55
52
56
```
53
57
gcloud auth application-default login
@@ -56,7 +60,7 @@ To remove all billing components from the project
56
60
To double check, run ```gcloud auth list```
57
61
To set active account, run gcloud config set account `ACCOUNT`
58
62
59
-
3. Enable base services:
63
+
**3. Enable base services:**
60
64
61
65
```
62
66
gcloud services enable \
@@ -65,25 +69,36 @@ To remove all billing components from the project
65
69
vpcaccess.googleapis.com
66
70
```
67
71
68
-
4. Build base image
72
+
**4. Build base image**
69
73
70
74
```
71
75
gcloud builds submit
72
76
```
73
77
74
-
5. Run ```./test```
78
+
**5. Run**```./test```
75
79
76
80
Check the output url from Cloud Run
77
81
78
-
## Migrate your models:
79
-
* Go to Cloud SQL to get your connection name. It should be in the format: {PROJECT_ID}:{SQL_INSTANCE_REGION}:{SQL_INSTANCE_NAME}.
80
-
* Run ```PRODUCTION_MODE="local" python3 manage.py runserver --insecure 0.0.0.0:8080``` to test if the app can be run locally and connected to Cloud SQL.
82
+
## Local deployment:
83
+
1. Go to Cloud SQL to get your connection name. It should be in the format: ```{PROJECT_ID}:{SQL_INSTANCE_REGION}:{SQL_INSTANCE_NAME}```
84
+
2. In another terminal, run ```./cloud_sql_proxy -instances={CONNECTION_NAME}=tcp:0.0.0.0:8002```
85
+
3. Run ```PRODUCTION_MODE="local" python3 manage.py runserver --insecure 0.0.0.0:8080``` to run the app locally and connect to Cloud SQL.
86
+
87
+
### Django models migration
88
+
1. Follow steps in **local deployment**
89
+
2. On your app's terminal, run**```PRODUCTION_MODE="local" python3 manage.py migrate```
90
+
3. Build base image to push new changes to Container Registry
91
+
92
+
```
93
+
gcloud builds submit
94
+
```
95
+
96
+
4. Run ```./test```
81
97
82
-
* In another terminal, run ```./cloud_sql_proxy -instances={CONNECTION_NAME}=tcp:0.0.0.0:8002```
83
-
* On your app's terminal, run ```PRODUCTION_MODE="local" python3 manage.py migrate```
98
+
Check the output url from Cloud Run with new changes
84
99
85
-
* Run step 4 and step 5 in *How to run* again to apply new changes on server.
86
100
101
+
---
87
102
Have issues or questions, visit [Issues](https://github.com/GoogleCloudPlatform/deploystack-serverless-e2e-photo-sharing-app/issues).
0 commit comments