-
Notifications
You must be signed in to change notification settings - Fork 56
/
Makefile
83 lines (75 loc) · 1.97 KB
/
Makefile
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
SHELL = bash
.ONESHELL:
.PHONY: run
run:
@echo Run server
. venv/bin/activate
./project/manage.py runserver
.PHONY: install
install: remove
@echo Create python virtual environment
python3 -m venv venv
. venv/bin/activate
@echo Install dependencies
pip install -r requirements.txt
cp .env.example .env
make -s create-project
.PHONY: create-project
create-project:
@echo Create django project
django-admin startproject project
@echo Create symlink
ln -s ${CURDIR} project/profilemaker
@echo Edit "'project/project/settings.py'"
printf '%s\n' \
"import os" \
"from dotenv import load_dotenv" \
"" \
"INSTALLED_APPS = [" \
" 'django.contrib.admin'," \
" 'django.contrib.auth'," \
" 'django.contrib.contenttypes'," \
" 'django.contrib.sessions'," \
" 'django.contrib.messages'," \
" 'django.contrib.staticfiles'," \
" 'profilemaker'," \
" 'bootstrap3'," \
" 'jquery'," \
"]" \
"" \
" 'ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS')'" \
" 'CSRF_TRUSTED_ORIGINS = os.getenv('CSRF_TRUSTED_ORIGINS')'" \
" 'DEBUG = os.getenv('DEBUG')'" \
" 'SECRET_KEY = os.getenv('SECRET_KEY')'"
>> project/project/settings.py
@echo Edit "'project/project/urls.py'"
printf '%s\n' \
"" \
"from django.urls import include, path" \
"from django.contrib.staticfiles.urls import staticfiles_urlpatterns" \
"" \
"urlpatterns = [" \
" path(\"\", include(\"profilemaker.urls\"))," \
"]" \
"urlpatterns += staticfiles_urlpatterns()" \
>> project/project/urls.py
@echo Init db
cd project
./manage.py migrate
.PHONY: remove
remove:
@echo "Erase 'venv' & 'project' directories"
rm -rf venv project
rm -f .env
.PHONY: up
up:
docker run -d --rm --name profilemaker -p 8000:8000 -v ${PWD}/extensions:/code/extensions firefox-profilemaker:latest
.PHONY: down
down:
docker stop profilemaker
.PHONY: build
build:
docker build . -t firefox-profilemaker:latest
.PHONY: shell
shell:
docker exec -it profilemaker /bin/sh