-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fe269a
commit ed199e1
Showing
20 changed files
with
567 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
venv | ||
db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
.idea/ | ||
static/ | ||
|
||
db/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
repos: | ||
- repo: https://github.com/PyCQA/isort | ||
rev: '5.10.1' | ||
hooks: | ||
- id: isort | ||
args: ['--profile=black'] | ||
- repo: https://github.com/psf/black | ||
rev: '22.3.0' | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: '4.0.1' | ||
hooks: | ||
- id: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM python:3.9 | ||
|
||
ARG APPENV=prod | ||
|
||
ENV DJANGO_SETTINGS_MODULE=drfboilerplate.settings.${APPENV} | ||
|
||
WORKDIR /code | ||
COPY requirements.txt /code/requirements.txt | ||
RUN pip install -r requirements.txt | ||
RUN mkdir static | ||
COPY . /code/ | ||
|
||
EXPOSE 8001 | ||
|
||
CMD gunicorn --bind=0.0.0.0:8001 --timeout=10 drfboilerplate.wsgi:application -k gevent --log-level=debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
DC_FILE ?= docker-compose.yml | ||
|
||
build: | ||
$(info ===> Building Docker image) | ||
@docker-compose -f $(DC_FILE) build | ||
|
||
local: | ||
$(info ===> Starting Docker containers) | ||
@docker-compose -f $(DC_FILE) up | ||
|
||
shell: | ||
@docker-compose -f $(DC_FILE) run --rm web python manage.py shell | ||
|
||
tests: | ||
$(info ==> Running tests) | ||
@docker-compose -f $(DC_FILE) run --rm web python manage.py test | ||
|
||
makemigrations: | ||
$(info ==> Making migrations) | ||
@docker-compose -f $(DC_FILE) run --rm web python manage.py makemigrations | ||
|
||
migrate: | ||
$(info ==> Migrating) | ||
@docker-compose -f $(DC_FILE) run --rm web python manage.py migrate | ||
|
||
collectstatic: | ||
$(info ==> Collecting statics) | ||
@docker-compose -f $(DC_FILE) run --rm web python manage.py collectstatic --noinput | ||
|
||
superuser: | ||
@docker-compose -f $(DC_FILE) run --rm web python manage.py createsuperuser | ||
|
||
bash: | ||
@docker-compose -f $(DC_FILE) run --rm web bash | ||
|
||
drop_db: | ||
@docker-compose -f $(DC_FILE) rm -s -v db | ||
rm -r db | ||
|
||
stop: | ||
$(info ==> Stoping all containers) | ||
@docker-compose -f $(DC_FILE) stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copbackend | ||
|
||
## Setup guide | ||
1. Install docker and docker-compose. Look [here](https://docs.docker.com/desktop/) for docs | ||
2. We're currently using `make` to build our app. It's installed by default in most of linux distros. For Windows users | ||
it's more complicated. Look [here](https://stackoverflow.com/questions/32127524/how-to-install-and-use-make-in-windows) for more info. | ||
In case you'll have a problem with `make` you can use commands defined in `makefile` directly. | ||
3. Install pre-commit: | ||
```shell | ||
pre-commit install | ||
``` | ||
4. Now you're ready to build our app!!! Let's hop in: | ||
```shell | ||
make build | ||
``` | ||
5. Our App serves static files (css stylesheets, fonts, images and so on) we need to collect 'em. | ||
This command would create a `static` directory. Look there if you're interested, what's inside ;) | ||
```shell | ||
make collectstatic | ||
``` | ||
6. It's time to create tables in database (docker container with database)! | ||
```shell | ||
make migrate | ||
``` | ||
7. Create superuser. | ||
```shell | ||
make superuser | ||
``` | ||
8. Start the app! | ||
```shell | ||
make local | ||
``` | ||
9. Open app on web browser `http://0.0.0.0:8001/admin/`. You can log in with superuser credentials. | ||
## Start your adventure here! | ||
Soon we'll give ya your first tasks, but now feel free to look around the project. We recommend to look on [swagger endpoint](http://0.0.0.0:8001/swagger/) as well as [admin page](http://0.0.0.0:8001/admin/). | ||
|
||
## Tips & tricks | ||
1. Don't be afraid to ask questions. We're here to help ya! | ||
2. Debug app with [Postman](https://www.postman.com/) or [Insomnia](https://insomnia.rest/) | ||
3. If you're a student, you can use Pycharm Pro for free (and other amazing staff). Just enroll for [Github Student Pack](https://education.github.com/pack). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: "3.9" | ||
|
||
services: | ||
db: | ||
image: postgres | ||
volumes: | ||
- ./db:/var/lib/postgresql/data | ||
env_file: | ||
- .env | ||
|
||
web: | ||
build: | ||
context: . | ||
args: | ||
APPENV: "local" | ||
command: gunicorn --bind=0.0.0.0:8001 --timeout=10 drfboilerplate.wsgi:application --log-level debug -k gevent --reload | ||
env_file: | ||
- .env | ||
volumes: | ||
- .:/code | ||
ports: | ||
- "8001:8001" | ||
depends_on: | ||
- db |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Django settings for copywriter project. | ||
Generated by 'django-admin startproject' using Django 3.2.7. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/3.2/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/3.2/ref/settings/ | ||
""" | ||
from drfboilerplate.settings.prod import * # noqa: F403, F401 | ||
|
||
DEBUG = True | ||
|
||
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from drfboilerplate.settings.prod import * # noqa: F403, F401 | ||
|
||
DEBUG = True | ||
CORS_ALLOWED_ORIGINS = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from drfboilerplate.settings.prod import * # noqa: F403, F401 | ||
|
||
DEBUG = True | ||
CORS_ALLOW_ALL_ORIGINS = True |
Oops, something went wrong.