Spaces:
Runtime error
Runtime error
Upload 11 files
Browse files- .env.dev +9 -0
- .env.prod +9 -0
- .env.prod.db +3 -0
- .gitignore +139 -0
- Dockerfile +17 -0
- LICENSE +21 -0
- docker-compose.dev.yml +24 -0
- docker-compose.yml +44 -0
- init-letsencrypt.sh +80 -0
- manage.py +22 -0
- requirements.txt +37 -0
.env.dev
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
DEBUG=1
|
2 |
+
SECRET_KEY=^il&w&37030%c0kbg@9(h+k(jsps53_)brjyw)mksmj=*c^5vf
|
3 |
+
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
|
4 |
+
SQL_ENGINE=django.db.backends.postgresql
|
5 |
+
SQL_DATABASE=do_it_django_dev
|
6 |
+
SQL_USER=do_it_django_db_user
|
7 |
+
SQL_PASSWORD=do_it_django_db_password
|
8 |
+
SQL_HOST=db
|
9 |
+
SQL_PORT=5432
|
.env.prod
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
DEBUG=0
|
2 |
+
SECRET_KEY=i+6g*^klw@jjoo9-w#63)6dmd6(t+32ef0uzgc+)x*v06-ex(9
|
3 |
+
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
|
4 |
+
SQL_ENGINE=django.db.backends.postgresql
|
5 |
+
SQL_DATABASE=do_it_django_prod
|
6 |
+
SQL_USER=do_it_django_db_user_prod
|
7 |
+
SQL_PASSWORD=do_it_django_db_password_prod
|
8 |
+
SQL_HOST=db
|
9 |
+
SQL_PORT=5432
|
.env.prod.db
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
POSTGRES_USER=do_it_django_db_user_prod
|
2 |
+
POSTGRES_PASSWORD=do_it_django_db_password_prod
|
3 |
+
POSTGRES_DB=do_it_django_prod
|
.gitignore
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
pip-wheel-metadata/
|
24 |
+
share/python-wheels/
|
25 |
+
*.egg-info/
|
26 |
+
.installed.cfg
|
27 |
+
*.egg
|
28 |
+
MANIFEST
|
29 |
+
|
30 |
+
# PyInstaller
|
31 |
+
# Usually these files are written by a python script from a template
|
32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33 |
+
*.manifest
|
34 |
+
*.spec
|
35 |
+
|
36 |
+
# Installer logs
|
37 |
+
pip-log.txt
|
38 |
+
pip-delete-this-directory.txt
|
39 |
+
|
40 |
+
# Unit test / coverage reports
|
41 |
+
htmlcov/
|
42 |
+
.tox/
|
43 |
+
.nox/
|
44 |
+
.coverage
|
45 |
+
.coverage.*
|
46 |
+
.cache
|
47 |
+
nosetests.xml
|
48 |
+
coverage.xml
|
49 |
+
*.cover
|
50 |
+
*.py,cover
|
51 |
+
.hypothesis/
|
52 |
+
.pytest_cache/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
target/
|
76 |
+
|
77 |
+
# Jupyter Notebook
|
78 |
+
.ipynb_checkpoints
|
79 |
+
|
80 |
+
# IPython
|
81 |
+
profile_default/
|
82 |
+
ipython_config.py
|
83 |
+
|
84 |
+
# pyenv
|
85 |
+
.python-version
|
86 |
+
|
87 |
+
# pipenv
|
88 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
89 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
90 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
91 |
+
# install all needed dependencies.
|
92 |
+
#Pipfile.lock
|
93 |
+
|
94 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
95 |
+
__pypackages__/
|
96 |
+
|
97 |
+
# Celery stuff
|
98 |
+
celerybeat-schedule
|
99 |
+
celerybeat.pid
|
100 |
+
|
101 |
+
# SageMath parsed files
|
102 |
+
*.sage.py
|
103 |
+
|
104 |
+
# Environments
|
105 |
+
.env
|
106 |
+
.venv
|
107 |
+
env/
|
108 |
+
venv/
|
109 |
+
ENV/
|
110 |
+
env.bak/
|
111 |
+
venv.bak/
|
112 |
+
|
113 |
+
# Spyder project settings
|
114 |
+
.spyderproject
|
115 |
+
.spyproject
|
116 |
+
|
117 |
+
# Rope project settings
|
118 |
+
.ropeproject
|
119 |
+
|
120 |
+
# mkdocs documentation
|
121 |
+
/site
|
122 |
+
|
123 |
+
# mypy
|
124 |
+
.mypy_cache/
|
125 |
+
.dmypy.json
|
126 |
+
dmypy.json
|
127 |
+
|
128 |
+
# Pyre type checker
|
129 |
+
.pyre/
|
130 |
+
|
131 |
+
# Pycharm
|
132 |
+
.idea/
|
133 |
+
|
134 |
+
migrations/
|
135 |
+
|
136 |
+
_media/
|
137 |
+
|
138 |
+
.env.prod
|
139 |
+
.env.prod.db
|
Dockerfile
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# pull official base image
|
2 |
+
FROM python:3.8.0-alpine
|
3 |
+
|
4 |
+
# set work directory
|
5 |
+
WORKDIR /usr/src/app
|
6 |
+
|
7 |
+
# set environment variables
|
8 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
9 |
+
ENV PYTHONUNBUFFERED 1
|
10 |
+
|
11 |
+
RUN apk update
|
12 |
+
RUN apk add postgresql-dev gcc python3-dev musl-dev zlib-dev jpeg-dev #--(5.2)
|
13 |
+
|
14 |
+
COPY . /usr/src/app/
|
15 |
+
# install dependencies
|
16 |
+
RUN pip install --upgrade pip
|
17 |
+
RUN pip install -r requirements.txt
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2020 SaintDragon2
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
docker-compose.dev.yml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
web:
|
5 |
+
build: .
|
6 |
+
command: gunicorn do_it_django_prj.wsgi:application --bind 0.0.0.0:8000
|
7 |
+
volumes:
|
8 |
+
- ./:/usr/src/app/
|
9 |
+
ports:
|
10 |
+
- 8000:8000
|
11 |
+
env_file:
|
12 |
+
- ./.env.dev
|
13 |
+
depends_on:
|
14 |
+
- db
|
15 |
+
db:
|
16 |
+
image: postgres:12.0-alpine
|
17 |
+
volumes:
|
18 |
+
- postgres_data:/var/lib/postgresql/data/
|
19 |
+
environment:
|
20 |
+
- POSTGRES_USER=do_it_django_db_user
|
21 |
+
- POSTGRES_PASSWORD=do_it_django_db_password
|
22 |
+
- POSTGRES_DB=do_it_django_dev
|
23 |
+
volumes:
|
24 |
+
postgres_data:
|
docker-compose.yml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
nginx:
|
5 |
+
build: ./nginx
|
6 |
+
volumes:
|
7 |
+
- static_volume:/usr/src/app/_static
|
8 |
+
- media_volume:/usr/src/app/_media
|
9 |
+
- ./data/certbot/conf:/etc/letsencrypt
|
10 |
+
- ./data/certbot/www:/var/www/certbot
|
11 |
+
ports:
|
12 |
+
- 80:80
|
13 |
+
- 443:443
|
14 |
+
depends_on:
|
15 |
+
- web
|
16 |
+
certbot:
|
17 |
+
image: certbot/certbot
|
18 |
+
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
|
19 |
+
volumes:
|
20 |
+
- ./data/certbot/conf:/etc/letsencrypt
|
21 |
+
- ./data/certbot/www:/var/www/certbot
|
22 |
+
web:
|
23 |
+
build: .
|
24 |
+
command: gunicorn do_it_django_prj.wsgi:application --bind 0.0.0.0:8000
|
25 |
+
volumes:
|
26 |
+
- static_volume:/usr/src/app/_static
|
27 |
+
- media_volume:/usr/src/app/_media
|
28 |
+
- ./:/usr/src/app/
|
29 |
+
expose:
|
30 |
+
- 8000
|
31 |
+
env_file:
|
32 |
+
- ./.env.prod
|
33 |
+
depends_on:
|
34 |
+
- db
|
35 |
+
db:
|
36 |
+
image: postgres:12.0-alpine
|
37 |
+
volumes:
|
38 |
+
- postgres_data:/var/lib/postgresql/data/
|
39 |
+
env_file:
|
40 |
+
- ./.env.prod.db
|
41 |
+
volumes:
|
42 |
+
postgres_data:
|
43 |
+
static_volume:
|
44 |
+
media_volume:
|
init-letsencrypt.sh
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
if ! [ -x "$(command -v docker-compose)" ]; then
|
4 |
+
echo 'Error: docker-compose is not installed.' >&2
|
5 |
+
exit 1
|
6 |
+
fi
|
7 |
+
|
8 |
+
domains=(sungyonglee.com www.sungyonglee.com)
|
9 |
+
rsa_key_size=4096
|
10 |
+
data_path="./data/certbot"
|
11 |
+
email="[email protected]" # Adding a valid address is strongly recommended
|
12 |
+
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits
|
13 |
+
|
14 |
+
if [ -d "$data_path" ]; then
|
15 |
+
read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision
|
16 |
+
if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then
|
17 |
+
exit
|
18 |
+
fi
|
19 |
+
fi
|
20 |
+
|
21 |
+
|
22 |
+
if [ ! -e "$data_path/conf/options-ssl-nginx.conf" ] || [ ! -e "$data_path/conf/ssl-dhparams.pem" ]; then
|
23 |
+
echo "### Downloading recommended TLS parameters ..."
|
24 |
+
mkdir -p "$data_path/conf"
|
25 |
+
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "$data_path/conf/options-ssl-nginx.conf"
|
26 |
+
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "$data_path/conf/ssl-dhparams.pem"
|
27 |
+
echo
|
28 |
+
fi
|
29 |
+
|
30 |
+
echo "### Creating dummy certificate for $domains ..."
|
31 |
+
path="/etc/letsencrypt/live/$domains"
|
32 |
+
mkdir -p "$data_path/conf/live/$domains"
|
33 |
+
docker-compose run --rm --entrypoint "\
|
34 |
+
openssl req -x509 -nodes -newkey rsa:4096 -days 1\
|
35 |
+
-keyout '$path/privkey.pem' \
|
36 |
+
-out '$path/fullchain.pem' \
|
37 |
+
-subj '/CN=localhost'" certbot
|
38 |
+
echo
|
39 |
+
|
40 |
+
|
41 |
+
echo "### Starting nginx ..."
|
42 |
+
docker-compose up --force-recreate -d nginx
|
43 |
+
echo
|
44 |
+
|
45 |
+
echo "### Deleting dummy certificate for $domains ..."
|
46 |
+
docker-compose run --rm --entrypoint "\
|
47 |
+
rm -Rf /etc/letsencrypt/live/$domains && \
|
48 |
+
rm -Rf /etc/letsencrypt/archive/$domains && \
|
49 |
+
rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot
|
50 |
+
echo
|
51 |
+
|
52 |
+
|
53 |
+
echo "### Requesting Let's Encrypt certificate for $domains ..."
|
54 |
+
#Join $domains to -d args
|
55 |
+
domain_args=""
|
56 |
+
for domain in "${domains[@]}"; do
|
57 |
+
domain_args="$domain_args -d $domain"
|
58 |
+
done
|
59 |
+
|
60 |
+
# Select appropriate email arg
|
61 |
+
case "$email" in
|
62 |
+
"") email_arg="--register-unsafely-without-email" ;;
|
63 |
+
*) email_arg="--email $email" ;;
|
64 |
+
esac
|
65 |
+
|
66 |
+
# Enable staging mode if needed
|
67 |
+
if [ $staging != "0" ]; then staging_arg="--staging"; fi
|
68 |
+
|
69 |
+
docker-compose run --rm --entrypoint "\
|
70 |
+
certbot certonly --webroot -w /var/www/certbot \
|
71 |
+
$staging_arg \
|
72 |
+
$email_arg \
|
73 |
+
$domain_args \
|
74 |
+
--rsa-key-size $rsa_key_size \
|
75 |
+
--agree-tos \
|
76 |
+
--force-renewal" certbot
|
77 |
+
echo
|
78 |
+
|
79 |
+
echo "### Reloading nginx ..."
|
80 |
+
docker-compose exec nginx nginx -s reload
|
manage.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
"""Django's command-line utility for administrative tasks."""
|
3 |
+
import os
|
4 |
+
import sys
|
5 |
+
|
6 |
+
|
7 |
+
def main():
|
8 |
+
"""Run administrative tasks."""
|
9 |
+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'do_it_django_prj.settings')
|
10 |
+
try:
|
11 |
+
from django.core.management import execute_from_command_line
|
12 |
+
except ImportError as exc:
|
13 |
+
raise ImportError(
|
14 |
+
"Couldn't import Django. Are you sure it's installed and "
|
15 |
+
"available on your PYTHONPATH environment variable? Did you "
|
16 |
+
"forget to activate a virtual environment?"
|
17 |
+
) from exc
|
18 |
+
execute_from_command_line(sys.argv)
|
19 |
+
|
20 |
+
|
21 |
+
if __name__ == '__main__':
|
22 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
asgiref==3.2.10
|
2 |
+
backcall==0.2.0
|
3 |
+
beautifulsoup4==4.9.1
|
4 |
+
certifi==2020.6.20
|
5 |
+
chardet==3.0.4
|
6 |
+
colorama==0.4.3
|
7 |
+
decorator==4.4.2
|
8 |
+
defusedxml==0.6.0
|
9 |
+
Django==3.1.1
|
10 |
+
django-allauth==0.42.0
|
11 |
+
django-crispy-forms==1.9.2
|
12 |
+
django-extensions==3.0.9
|
13 |
+
django-markdownx==3.0.1
|
14 |
+
gunicorn==20.0.4
|
15 |
+
idna==2.10
|
16 |
+
importlib-metadata==2.0.0
|
17 |
+
ipython==7.18.1
|
18 |
+
ipython-genutils==0.2.0
|
19 |
+
jedi==0.17.2
|
20 |
+
Markdown==3.2.2
|
21 |
+
oauthlib==3.1.0
|
22 |
+
parso==0.7.1
|
23 |
+
pickleshare==0.7.5
|
24 |
+
Pillow==7.2.0
|
25 |
+
prompt-toolkit==3.0.7
|
26 |
+
psycopg2==2.8.6
|
27 |
+
Pygments==2.7.1
|
28 |
+
python3-openid==3.2.0
|
29 |
+
pytz==2020.1
|
30 |
+
requests==2.24.0
|
31 |
+
requests-oauthlib==1.3.0
|
32 |
+
soupsieve==2.0.1
|
33 |
+
sqlparse==0.3.1
|
34 |
+
traitlets==5.0.4
|
35 |
+
urllib3==1.25.10
|
36 |
+
wcwidth==0.2.5
|
37 |
+
zipp==3.2.0
|