Skip to content

Commit 3f6bf7f

Browse files
committed
Upgraded to Django 5.2 and Rav
1 parent 260663e commit 3f6bf7f

File tree

6 files changed

+155
-109
lines changed

6 files changed

+155
-109
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,24 @@ COPY requirements.txt /tmp/requirements.txt
4141
COPY ./src /code
4242

4343
# Install the Python project requirements
44+
RUN pip install --upgrade pip
4445
RUN pip install -r /tmp/requirements.txt
46+
RUN pip install gunicorn rav --upgrade
4547

4648
ARG DJANGO_SECRET_KEY
4749
ENV DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY}
4850

4951
ARG DJANGO_DEBUG=0
5052
ENV DJANGO_DEBUG=${DJANGO_DEBUG}
5153

54+
55+
COPY ./rav.yaml /tmp/rav.yaml
56+
RUN rav download staticfiles_prod -f /tmp/rav.yaml
57+
5258
# database isn't available during build
5359
# run any other commands that do not need the database
5460
# such as:
55-
RUN python manage.py vendor_pull
61+
# RUN python manage.py vendor_pull
5662
RUN python manage.py collectstatic --noinput
5763
# whitenoise -> s3
5864

README.md

Lines changed: 35 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ The goal of this project is to learn how to create a reusable foundation for bui
99

1010
- Deploy Django on [Railway](https://kirr.co/qysgeu) with [this Dockerfile and guide](https://www.codingforentrepreneurs.com/blog/deploy-django-on-railway-with-this-dockerfile/)
1111
- Create a One-Off Secret Key for Django [blog post](https://www.codingforentrepreneurs.com/blog/create-a-one-off-django-secret-key/)
12-
13-
14-
Thank you to [Neon](https://kirr.co/eu0b31) for helping bring this course to life!
12+
- This repo started as a course [SaaS Foundations](https://www.codingforentrepreneurs.com/courses/saas-foundations).
13+
- Need a more advanced SaaS template? Check out [CFE Run](https://run.codingforentrepreneurs.com/).
1514

1615

1716
## Getting Started
@@ -38,11 +37,15 @@ c:\Python312\python.exe -m venv venv
3837
.\venv\Scripts\activate
3938
```
4039

41-
### Install Requirements
40+
### Install Requirements with Rav
41+
[Rav](https://github.com/jmitchel3/rav) is a simple way to run commands and download static files (css, images, js, etc) from external sources.
42+
4243
```bash
4344
# with venv activated
44-
pip install pip --upgrade && pip install -r requirements.txt
45+
pip install pip rav --upgrade
46+
rav run install
4547
```
48+
> Use `python -m rav run install` if for some reason `rav` is not in your path.
4649
4750
### Sample dotenv to dotnev
4851

@@ -81,64 +84,6 @@ python -c 'import secrets; print(secrets.token_urlsafe(64))'
8184
Once you have this value, add update `DJANGO_SECRET_KEY` in `.env`.
8285

8386

84-
### Create [Neon](https://kirr.co/eu0b31) Postgres Database
85-
86-
87-
#### Install Neon CLI
88-
Using the [Neon cli](https://neon.tech/docs/reference/cli-install) via [homebrew](https://brew.sh/):
89-
90-
```bash
91-
brew install neonctl
92-
```
93-
94-
#### Login to Neon CLI
95-
96-
```bash
97-
neonctl auth
98-
```
99-
This will open a browser window to login.
100-
101-
#### Create a new Neon project (optional)
102-
```bash
103-
neonctl projects create --name saas
104-
```
105-
106-
#### Get the Project ID
107-
108-
Once created, get the project id:
109-
110-
```bash
111-
neonctl projects list
112-
```
113-
Projects
114-
115-
```bash
116-
┌──────────────────────────┬────────────────────────────┬───────────────┬──────────────────────┐
117-
│ Id │ Name │ Region Id │ Created At │
118-
├──────────────────────────┼────────────────────────────┼───────────────┼──────────────────────┤
119-
│ steep-base-11409687 │ saas │ aws-us-east-2 │ 2024-06-02T04:03:07Z │
120-
└──────────────────────────┴────────────────────────────┴───────────────┴──────────────────────┘
121-
```
122-
123-
```bash
124-
PROJECT_ID=steep-base-11409687
125-
```
126-
Replace `steep-base-11409687` with your project id.
127-
128-
Or using the shortcut:
129-
130-
```bash
131-
PROJECT_ID=$(neonctl projects list | grep "saas" | awk -F '' '{print $2}' | xargs)
132-
```
133-
134-
#### Get the Database Connection String
135-
136-
```bash
137-
neonctl connection-string --project-id "$PROJECT_ID"
138-
```
139-
Set this value to `DATABASE_URL` in `.env`.
140-
141-
14287
### Run Migrations
14388

14489
```bash
@@ -176,4 +121,30 @@ python manage.py runserver
176121

177122
Ready to roll! 🚀
178123

179-
Much more coming soon!
124+
125+
### Useful Rav Commands
126+
127+
Review the [rav.yaml](./rav.yaml) (or [rav](https://github.com/jmitchel3/rav) documentation) for available command shortcuts, here are some useful ones:
128+
129+
- `rav run install` - Install requirements based on `scripts.install`
130+
- `rav run install_dev` - Install requirements for development
131+
- `rav run makemigrations` - Make migrations
132+
- `rav run migrate` - Run migrations
133+
- `rav run dev` - Run the development server
134+
- `rav run test` - Run the tests
135+
- `rav run vendors_pull` - Download vendor static files
136+
- `rav run collectstatic` - Collect static files
137+
- `rav download staticfiles_prod` - Download vendor static files for production
138+
- `rav download staticfiles_dev` - Download vendor static files for development
139+
140+
141+
142+
### Changelog
143+
144+
- 2025-09-02:
145+
- Upgraded to Django 5.2
146+
- Added Slippers for better AllAuth UI Support
147+
- Implemented Rav to manage requirements and static files
148+
- Updated Dockerfile to use Rav
149+
- Updated README to include Rav
150+
- Dropped only Neon in favor of any Postgres database (aim to make it more generic)

rav.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
description: |
2+
rav is a simple tool to help run commands.
3+
install with pip install rav
4+
5+
scripts:
6+
install:
7+
- venv/bin/python -m pip install -r requirements.txt
8+
install_dev:
9+
- venv/bin/python -m pip install -r requirements.txt
10+
- venv/bin/python -m pip install -r requirements.dev.txt
11+
makemigrations:
12+
- venv/bin/python src/manage.py makemigrations
13+
migrate:
14+
- venv/bin/python src/manage.py migrate
15+
dev:
16+
- venv/bin/python src/manage.py runserver 8080
17+
test:
18+
- cd src && ../venv/bin/python manage.py test
19+
vendors_pull:
20+
# grab vendor files to serve via whitenoise
21+
- venv/bin/rav download staticfiles_dev
22+
collectstatic:
23+
- cd src && ../venv/bin/python manage.py collectstatic --noinput
24+
docker_build:
25+
- docker build -t cfe-saas-foundations:latest .
26+
docker_stop:
27+
- docker stop $(docker ps -q --filter ancestor=cfe-saas-foundations:latest)
28+
docker_run:
29+
- docker run --rm --env-file .env -e PORT=8080 -p 8080:8080 cfe-saas-foundations:latest
30+
docker_shell:
31+
- docker run --rm -it --env-file .env cfe-saas-foundations:latest /bin/bash
32+
33+
downloads:
34+
staticfiles_prod:
35+
name: vendor
36+
destination: staticfiles/vendors
37+
verbose: true
38+
raise_on_error: true
39+
overwrite: true
40+
files:
41+
- name: saas-theme.min.css
42+
overwrite: false
43+
url: https://raw.githubusercontent.com/codingforentrepreneurs/SaaS-Foundations/main/src/staticfiles/theme/saas-theme.min.css
44+
- name: flowbite.min.css
45+
overwrite: false
46+
url: https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.5.2/flowbite.min.css
47+
- name: flowbite.min.js
48+
overwrite: false
49+
url: https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.5.2/flowbite.min.js
50+
- name: flowbite.min.js.map
51+
overwrite: false
52+
url: https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.5.2/flowbite.min.js.map
53+
staticfiles_dev:
54+
name: vendor
55+
destination: src/staticfiles/vendors
56+
verbose: true
57+
raise_on_error: true
58+
overwrite: true
59+
files:
60+
- name: saas-theme.min.css
61+
overwrite: false
62+
url: https://raw.githubusercontent.com/codingforentrepreneurs/SaaS-Foundations/main/src/staticfiles/theme/saas-theme.min.css
63+
- name: flowbite.min.css
64+
overwrite: false
65+
url: https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.5.2/flowbite.min.css
66+
- name: flowbite.min.js
67+
overwrite: false
68+
url: https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.5.2/flowbite.min.js
69+
- name: flowbite.min.js.map
70+
overwrite: false
71+
url: https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.5.2/flowbite.min.js.map

requirements.dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rav

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Django>=5.0,<5.1
1+
Django>=5.2,<5.3
22
gunicorn
33
python-decouple
44
psycopg[binary]
@@ -8,4 +8,5 @@ whitenoise
88
django-allauth[socialaccount]
99
django-allauth-ui
1010
django-widget-tweaks
11-
stripe
11+
stripe
12+
slippers

0 commit comments

Comments
 (0)