|
1 | 1 | --- |
2 | | -sidebar_position: 2 |
3 | | -description: How to deploy Django to Render Deployment Platform |
| 2 | +title : Django - Deploy on render |
| 3 | +sidebar_label: Deploy Django on Render |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Deploy Django to Render |
7 | 7 |
|
8 | | -<SubHeading color="#25c2a0">How to deploy Django to Render Deployment Platform</SubHeading> |
| 8 | +<SubHeading color="#25c2a0">This page explains how to deploy Django on Render</SubHeading> |
9 | 9 |
|
10 | | -@Todo - General information Render Platform |
| 10 | +[Render](https://render.com/) fully supports **Python-based** applications and this page explains the steps that any developer can follow and deploy their apps using a minimal configuration. |
| 11 | +Any **Django** project can be deployed in two ways: |
11 | 12 |
|
12 | | -> Topics covered |
| 13 | +- As a Service: the deployed app runs standalone (not connected with other services) |
| 14 | +- As a Blueprint, where the Django App can be connected with other local services like cron, background tasks, or a React UI. |
13 | 15 |
|
14 | | -- `Render` Account Creation |
15 | | -- `Render` Account Settings |
16 | | -- The project to be deployed |
17 | | -- `Render` Environment set up |
18 | | -- `Render` Domain settings |
19 | | -- `Render` SSL certificates |
20 | | -- `Render` LIVE Service monitoring |
| 16 | +This page covers the case when Django is deployed as a service. |
21 | 17 |
|
22 | | -## `Render` Account Creation |
| 18 | +## Deploy as a Service |
23 | 19 |
|
24 | | -Render provide Social auth and email auth, based on your preference you can sign up with Render |
| 20 | +To deploy **Django** as a service, the steps are: |
25 | 21 |
|
26 | | -**IMG_render_signup** |
| 22 | +- Create a new Render account using GitHub |
| 23 | + - Using GitHub for authentication facilitates the deployment of the project from the sources directly |
| 24 | +- Navigate to the main Dashboard |
| 25 | +- Create a `New Service` |
| 26 | +- Connect a GitHub Repository. For DEMO we will use: |
| 27 | + - https://github.com/app-generator/django-admin-datta |
| 28 | +- Configure the project |
| 29 | + - Name |
| 30 | + - Runtime: Needs to be Python |
| 31 | + - Build Command |
| 32 | + - this is responsible to install modules, collect statics, and build DB |
| 33 | + - Start Command |
| 34 | + - here we need to call `Gunicorn` using the `app entry point` as input |
| 35 | + - Select the Instance Type |
| 36 | + - For this DEMO we will use a free one |
| 37 | + - Optionally, we can specify `ENV Variables`, and disable the `auto-deploy` |
| 38 | + - Confirm the action |
| 39 | + - click on `Create Service` |
27 | 40 |
|
28 | | -Once successfully signed up, the user is redirected Render dashboard and sees the screen like below: |
| 41 | +The steps with the related screens, are listed below: |
29 | 42 |
|
30 | | -**IMG_render_dashboard** |
| 43 | +### `Create new Service` |
31 | 44 |
|
32 | | -## `Render` Account Settings |
| 45 | + |
33 | 46 |
|
34 | | -The Next step is to connect the Render account with the GitHub account, If you sign up with GitHub then this step is automatically done. |
| 47 | +<br /> |
35 | 48 |
|
36 | | -**IMG_render_account_settings** |
| 49 | +### `Connect` a GitHub `Repository` |
37 | 50 |
|
38 | | -## The project to be deployed |
| 51 | +> This demonstration uses [Datta Able Django](https://github.com/app-generator/django-admin-datta) |
39 | 52 |
|
40 | | -Source project: https://github.com/app-generator/django-react-soft-dashboard |
| 53 | + |
41 | 54 |
|
42 | | -To deploy the Django app on Render we need to choose the **Web Service** option from the Dashboard as shown below: |
| 55 | +<br /> |
43 | 56 |
|
44 | | -**IMG_render_dashboard_web_service** |
| 57 | +### `Naming the Service` |
45 | 58 |
|
46 | | ---- |
| 59 | + |
47 | 60 |
|
48 | | -After selecting the web service option, the next step is to connect the GitHub project repository. On the next page, we can select the project from the linked account, with private or public visibility. |
| 61 | +<br /> |
49 | 62 |
|
50 | | -**IMG_render_web_service** |
| 63 | +### `Configure` the Service |
51 | 64 |
|
52 | | ---- |
| 65 | +This step is quite important because we need to inform Render that our project needs Python to run, and also what should be executed before going live. |
| 66 | +This open-source starter combines the build set up in single file named [build.sh](https://github.com/app-generator/django-datta-able/blob/master/build.sh) responsible with the following tasks: |
| 67 | + |
| 68 | +- Upgrade PIP (recommended to use a newer version) |
| 69 | +- Install modules via PIP |
| 70 | +- Collect Static |
| 71 | +- Migrate DB |
| 72 | + |
| 73 | +Another important setting is the `Start Command` that specify the entry point to be used by `Gunicorn`. For this starter, this is the value. |
| 74 | + |
| 75 | +`$ gunicorn core.wsgi:application` |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +<br /> |
53 | 80 |
|
54 | | -The next step is to edit deployment details. Here are the sections that need editing: |
| 81 | +### `Configure` the Instance |
55 | 82 |
|
56 | | -- **Name**: In this section, we should use a unique name for the web service. |
57 | | -- **Root Directory**: By default, the root directory is set to the top-level directory in your repository. We have also the possibility to select subfolders in case the project structure is modular and for instance, the backend and the frontend use different directories |
58 | | -- **Environment**: In this section, we should select the language used to code the product, Python in our case. |
59 | | -- **Region**:- The region where your web service runs, not required to update by default is `Oregon (US West)` |
60 | | -- **Branch**:- The repository branch used for your web service. |
61 | | -- **Build Command**: The shell script that executes all the steps to build the project |
62 | | -- **Start Command**: This section informs Gunicorn where to locate the entry point in our Django starter: `gunicorn core.wsgi:application` |
63 | | -- **Add Environment Variables** required by the starter in `Advanced` section. |
64 | | - - Python Version: `PYTHON_VERSION` = `3.10.4` |
65 | | - - `GUNICORN_CMD_ARGS` = `--preload --bind=0.0.0.0:2000` |
66 | | - - `PORT` = `2000` |
67 | | - - `DJANGO_ALLOWED_HOSTS` = `.onrender.com` |
68 | | -- **Auto-Deploy**: Render provide this option to trigger a new deployment on every push to the repository. In case this feature is not useful, set this option to "NO" for manually managed deployments |
| 83 | +Here we have two options: Free & Paid. For this deployment, a free instance was selected. |
69 | 84 |
|
70 | | -With all the above settings specified as per project requirements, we can confirm the action and actually Create the new Service. |
| 85 | + |
71 | 86 |
|
72 | | -**IMG_render_django_deployment_settings** |
| 87 | +<br /> |
73 | 88 |
|
74 | | -## `Render` Domain settings |
| 89 | +### `Confirm` & View Deployment Logs |
75 | 90 |
|
76 | | -Render by default provides the domain itself, but the user can set up a custom domain based as well. For more information feel free to access the official documentation regarding [custom domains](https://render.com/docs/custom-domains). |
| 91 | +Once the above set up is confirmed, Render will create a new page for the sevice where we can visualize the deployment logs and later, update the service settings. |
77 | 92 |
|
78 | | -## `Render` SSL certificates |
| 93 | + |
79 | 94 |
|
80 | | -Render Platform provides valid SSL certificates for all managed services, and also offers the possibility to customize the certificates. |
| 95 | +<br /> |
81 | 96 |
|
82 | | -## `Render` LIVE Service monitoring |
| 97 | +### Access the `LIVE Deployment` |
83 | 98 |
|
84 | | -Once the project is deployed, the users have the possibility to set up alerts in Health & Alerts section (Project Settings). |
| 99 | +At this point, the app should be up & running in the same way as [Datta Able](https://django-datta-able.appseed-srv1.com/) Deployment |
85 | 100 |
|
86 | | -The `Health Check Path` is the public URL of the project that should return a 200 status code on access. |
| 101 | + |
87 | 102 |
|
88 | | -Another option is to get notified via Email in case of Service failure. |
| 103 | +<br /> |
89 | 104 |
|
90 | | -## Links & Resources |
| 105 | +## Resources |
91 | 106 |
|
92 | | -- [Render Django deployment](https://render.com/docs/deploy-django) - Official Guide to deploy Django app on Render |
93 | | -- [Custom domains on render](https://render.com/docs/custom-domains) - Official Guide to setup custom domain |
94 | | -- [Shell Script](https://www.shellscript.sh/) - Official Guide to shell script |
95 | | -- [Django](https://www.djangoproject.com/) - Official Guide to Django Framework |
96 | | -- [Gunicorn](https://gunicorn.org/) - Official Guide to Gunicorn |
| 107 | +- 👉 More [Django Starters](https://appseed.us/apps/django/) - provided by `AppSeed` (free & paid) |
| 108 | +- 👉 Free [Support](https://appseed.us/support/) via Email & Discord |
0 commit comments