forked from nm-examples/wagtail-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (102 loc) · 3.13 KB
/
Makefile
File metadata and controls
120 lines (102 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Makefile for Docker Compose commands
# --- Un-comment based on the database you want to use --- #
DC = docker compose -f compose.yaml -f compose.sqlite3.override.yaml # SQLITE Database
# DC = docker compose -f compose.yaml -f compose.postgresql.override.yaml # PostgreSQL Database
# DC = docker compose -f compose.yaml -f compose.mysql.override.yaml # MySQL Database
# --- #
.PHONY: help
help:
@echo "Usage: make [target]"
@echo ""
@echo "Docker Compose commands"
@echo " build Build the Docker containers"
@echo " up Start the Docker containers"
@echo " down Stop and remove the Docker containers"
@echo " destroy Stop and remove the Docker containers, networks, and volumes"
@echo " run Run the Django development server"
@echo ""
@echo "Container commands"
@echo " migrate Run Django migrations"
@echo " superuser Create a superuser"
@echo " restoredb Restore the database from a backup"
@echo " sh Execute a command in a running container"
@echo " restart Restart the containers"
@echo ""
@echo "Miscellaneous"
@echo " quickstart Build, start, and run the containers (npm & docker)"
@echo " requirements Export requirements.txt (uv)"
@echo " clean Clean up generated files and folders (node_modules, static, media, etc.)"
@echo " frontend Build the frontend (npm)"
@echo " start Build the front end and start local development server (npm)"
@echo ""
# Build the containers
.PHONY: build
build:
$(DC) build
# Start the containers
.PHONY: up
up:
$(DC) up -d
# Stop and remove containers, networks, and volumes
.PHONY: down
down:
$(DC) down
# Restart the containers
.PHONY: restart
restart:
$(DC) restart
# Execute a command in a running container
.PHONY: sh
sh:
$(DC) exec app bash
# Run the Django development server
.PHONY: run
run:
$(DC) exec app python manage.py runserver 0.0.0.0:8000
# Stop and remove the Docker containers, networks, and volumes
.PHONY: destroy
destroy:
$(DC) down -v
# Run migrations
.PHONY: migrate
migrate:
$(DC) exec app python manage.py migrate
# Create a superuser
.PHONY: superuser
superuser:
$(DC) exec app python manage.py createsuperuser
# Collect static files
.PHONY: collectstatic
collectstatic:
$(DC) exec app python manage.py collectstatic --noinput
# Run tests, you will need to have run `make collectstatic` first
.PHONY: test
test:
$(DC) exec app python manage.py test
# Quickstart
.PHONY: quickstart
quickstart: frontend build up migrate collectstatic test run
# Build the fontend
.PHONY: frontend
frontend:
npm install
npm run build
# Start the frontend and run the local development server
.PHONY: start
start:
npm install
npm run build
npm run start
# Export requirements.txt
.PHONY: requirements
requirements:
uv export --no-hashes --no-dev --output-file requirements.txt --locked
# Clean up
.PHONY: clean
clean:
@echo "This will remove all generated files and folders (node_modules, static, media + db.sqlite3)"
@read -p "Are you sure? [y/N] " -n 1 -r; \
echo; \
if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
rm -rf ./node_modules ./static ./static_compiled ./media db.sqlite3; \
fi