Skip to content

Commit b3ec9a3

Browse files
docs: add vm and bare metal workflows flow chart
1 parent 4b5ecee commit b3ec9a3

File tree

8 files changed

+56
-14
lines changed

8 files changed

+56
-14
lines changed

.github/workflows/deploy-bare-metal.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
username: ${{ secrets.USERNAME }}
7171
password: ${{ secrets.SSH_PASSWORD }}
7272
port: 22
73-
source: "requirements.txt,api,backend,config,core,frontend,manage.py,drt.ini"
73+
source: "poetry.lock,pyproject.toml,api,backend,config,core,frontend,manage.py"
7474
target: "app_to_deploy"
7575

7676
- name: build the backend, the frontend and start the app's daemon
@@ -121,13 +121,17 @@ jobs:
121121
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~ Replaced current running code with new one ~~~~~~~~~~~~~~~~~~~~~~~~\n"
122122
123123
cd app
124-
python3 -m pip install -r requirements.txt
124+
python3 -m pip install --upgrade pip
125+
pip install poetry
126+
poetry install --no-dev
125127
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~ Installed python requirements successfully ~~~~~~~~~~~~~~~~~~~~~~~~\n"
126128
127-
python3 manage.py migrate && python3 manage.py collectstatic --no-input && python3 manage.py clearcache
129+
poetry run python3 manage.py migrate
130+
poetry run python3 manage.py collectstatic --no-input
131+
poetry run python3 manage.py clearcache
128132
129133
echo ${{ secrets.SSH_PASSWORD }} | sudo -S rm /etc/supervisord.d/drt.ini
130-
echo ${{ secrets.SSH_PASSWORD }} | sudo -S cp ./drt.ini /etc/supervisord.d/
134+
echo ${{ secrets.SSH_PASSWORD }} | sudo -S cp ./config/supervisor/drt.ini /etc/supervisord.d/
131135
echo ${{ secrets.SSH_PASSWORD }} | sudo -S supervisorctl update
132136
echo ${{ secrets.SSH_PASSWORD }} | sudo -S supervisorctl reread
133137
echo ${{ secrets.SSH_PASSWORD }} | sudo -S supervisorctl status drt

README.md

+43-2
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,52 @@ Nonetheless, this codebase has two deploy methods available via GitHub actions:
106106

107107
The `vm-deploy` branch will trigger this wokflow. You can use it to deploy the app to any Virtual Machine accessible via SSH (AWS EC2s, GCloud apps, Digital Ocean droplets, Hostgator VPSs, etc), and you would likely want to change the name of these branches to something more meaningful to your project.
108108

109+
This is what the workflow does:
110+
111+
```mermaid
112+
flowchart LR
113+
nv("Make changes to\nthe application") -- Commit --> n7("Build and test frontend\nand backend")
114+
n7 --> nf{"Success?"}
115+
nf -- Yes --> n2("Build and test docker\nimage")
116+
nf -- No --> n4("Cancel pipeline")
117+
n2 --> n5{"Success?"}
118+
n5 -- No --> n4
119+
n5 -- Yes --> nx("Publish docker image\nto GitHub packages")
120+
nx --> nj{"Success?"}
121+
nj -- No --> n4
122+
nj -- Yes --> nd("Deploy")
123+
nd --> nc("Login into VM and copy\ndocker compose file\nfrom repo")
124+
nc --> n6{"Success?"}
125+
n6 -- Yes --> no("Pull previously pushed Docker image\nand execute most recent\n docker compose file")
126+
n6 -- No --> n4
127+
no --> na{"Success?"}
128+
na -- No --> ng("Better check your\nsystem's health")
129+
na -- Yes --> nk("Updates are live")
130+
```
131+
109132
### Bare-metal Deploy Workflow
110133

111-
The `bare-metal-deploy` branches will trigger this workflow. You can use it to deploy the app straight on the host machine, without any virtualization. This is not recommended, but ou never know when you will need to deploy an app on a bare-metal machine 🤷‍♀️
134+
The `bare-metal-deploy` branches will trigger this workflow. You can use it to deploy the app straight on the host machine, without any virtualization. This is not recommended, but ou never know when you will need to deploy an app on a bare-metal machine 🤷‍♀️. This pipeline assumes that you've got Node.js, Python, [Gunicorn](https://gunicorn.org/) and [Supervisord](http://supervisord.org/) installed on the host machine.
112135

113-
You should configure these variables on a `.env` file on the root folder for the global configuration and a `.env` file for the frontend configuration under `frontend/.env` when developing. As for deploying the app, **you will need to set the same set of dev variables + some variables exclusively used in production environments as [_secrets_](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)**.
136+
This is what the workflow does:
137+
138+
```mermaid
139+
flowchart LR
140+
nv("Make changes to\nthe application") -- Commit --> n7("Build and test frontend\nand backend")
141+
n7 --> nf{"Success?"}
142+
nf -- Yes --> n2("Logs into host machine\nand copy all relevant files\nfrom repo to it")
143+
nf -- No --> n4("Cancel pipeline")
144+
n2 --> n5{"Success?"}
145+
n5 -- No --> n4
146+
n5 -- Yes --> nx("Builds the frontend\nand the backend")
147+
nx --> nj{"Success?"}
148+
nj -- No --> n4
149+
nj -- Yes --> nd("Deploy")
150+
nd --> nc("Starts gunicorn server under\nsupervisor to ensure the\nsystem is never down")
151+
na{"Success?"} -- No --> ng("Better check your\nsystem's health")
152+
na -- Yes --> nk("Updates are live")
153+
nc --> na
154+
```
114155

115156
### Configuration
116157

assets/Architecture.png

-35.3 KB
Binary file not shown.

assets/DeployWorkflow.jpg

-56.4 KB
Binary file not shown.
File renamed without changes.

frontend/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "django-react-typescript-frontend",
3-
"version": "1.0.0",
3+
"version": "0.1.0",
44
"main": "index.js",
55
"repository": "https://github.com/marcelovicentegc/django-react-typescript.git",
66
"author": "Marcelo Cardoso <dev@marcelo.page>",
@@ -38,8 +38,6 @@
3838
"@babel/core": "^7.24.7",
3939
"@babel/preset-env": "^7.24.7",
4040
"@babel/preset-react": "^7.24.7",
41-
"@commitlint/cli": "^8.3.5",
42-
"@commitlint/config-conventional": "^8.3.4",
4341
"@types/node": "^20.14.6",
4442
"@types/react": "^18.3.3",
4543
"@types/react-dom": "^18.3.0",
@@ -48,7 +46,6 @@
4846
"copy-webpack-plugin": "^5.1.1",
4947
"cross-env": "^6.0.3",
5048
"source-map-loader": "^0.2.4",
51-
"husky": "^4.2.5",
5249
"ts-loader": "^6.2.1",
5350
"internal-ip": "^5.0.0",
5451
"concurrently": "^8.2.2",

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "django-react-typescript",
3-
"version": "1.0.0",
4-
"description": "<p align=\"center\"> <img alt=\"django-react-typescript logo\" src=\"assets/Logo.png\" /> <p align=\"center\">Your favorite React-Django boilerplate.</p> </p>",
3+
"version": "0.1.0",
4+
"description": "This is an non-opinionated Django + React boilerplate built with great development experience and easy deployment in mind.",
55
"scripts": {
66
"bootstrap": "concurrently -n global,backend,frontend \"pnpm i\" \"poetry install\" \"cd frontend && pnpm i\"",
77
"setup:env": "sh ./scripts/setup_env.sh",

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tool.poetry]
22
name = "django-react-typescript"
3-
description = ""
3+
description = "This is an non-opinionated Django + React boilerplate built with great development experience and easy deployment in mind."
44
authors = ["marcelovicentegc <marcelovicentegc@gmail.com>"]
5-
license = "ISC"
5+
license = "MIT"
66
readme = "README.md"
77
package-mode = false
88

0 commit comments

Comments
 (0)