Skip to content

Commit 5804854

Browse files
committed
bootstrap
1 parent d80269c commit 5804854

19 files changed

+554
-0
lines changed

.gitignore

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
### Django ###
2+
*.log
3+
*.pot
4+
*.pyc
5+
__pycache__/
6+
local_settings.py
7+
db.sqlite3
8+
media
9+
10+
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
11+
# in your Git repository. Update and uncomment the following line accordingly.
12+
project/static/
13+
14+
### Linux ###
15+
*~
16+
17+
# temporary files which can be created if a process still has a handle open of a deleted file
18+
.fuse_hidden*
19+
20+
# KDE directory preferences
21+
.directory
22+
23+
# Linux trash folder which might appear on any partition or disk
24+
.Trash-*
25+
26+
# .nfs files are created when an open file is removed but is still being accessed
27+
.nfs*
28+
29+
### Python ###
30+
# Byte-compiled / optimized / DLL files
31+
*.py[cod]
32+
*$py.class
33+
34+
# C extensions
35+
*.so
36+
37+
# Distribution / packaging
38+
.Python
39+
build/
40+
develop-eggs/
41+
dist/
42+
downloads/
43+
eggs/
44+
.eggs/
45+
lib/
46+
lib64/
47+
parts/
48+
sdist/
49+
var/
50+
wheels/
51+
*.egg-info/
52+
.installed.cfg
53+
*.egg
54+
MANIFEST
55+
56+
# PyInstaller
57+
# Usually these files are written by a python script from a template
58+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
59+
*.manifest
60+
*.spec
61+
62+
# Installer logs
63+
pip-log.txt
64+
pip-delete-this-directory.txt
65+
66+
# Unit test / coverage reports
67+
htmlcov/
68+
.tox/
69+
.coverage
70+
.coverage.*
71+
.cache
72+
nosetests.xml
73+
coverage.xml
74+
*.cover
75+
.hypothesis/
76+
.pytest_cache/
77+
78+
# Translations
79+
*.mo
80+
81+
# Django stuff:
82+
83+
# Flask stuff:
84+
instance/
85+
.webassets-cache
86+
87+
# Scrapy stuff:
88+
.scrapy
89+
90+
# Sphinx documentation
91+
docs/_build/
92+
93+
# PyBuilder
94+
target/
95+
96+
# Jupyter Notebook
97+
.ipynb_checkpoints
98+
99+
# pyenv
100+
.python-version
101+
102+
# celery beat schedule file
103+
celerybeat-schedule
104+
105+
# SageMath parsed files
106+
*.sage.py
107+
108+
# Environments
109+
.env
110+
.venv
111+
env/
112+
venv/
113+
ENV/
114+
env.bak/
115+
venv.bak/
116+
117+
# Spyder project settings
118+
.spyderproject
119+
.spyproject
120+
121+
# Rope project settings
122+
.ropeproject
123+
124+
# mkdocs documentation
125+
/site
126+
127+
# mypy
128+
.mypy_cache/
129+
130+
### Python Patch ###
131+
.venv/
132+
133+
### VisualStudioCode ###
134+
.vscode/*
135+
!.vscode/settings.json
136+
!.vscode/tasks.json
137+
!.vscode/launch.json
138+
!.vscode/extensions.json

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: python
2+
3+
sudo: required
4+
5+
python:
6+
- "3.6"
7+
8+
services:
9+
- docker
10+
11+
install:
12+
- docker-compose pull
13+
- docker-compose build
14+
15+
script:
16+
- docker-compose run --service-ports web sh wait_for_postgres.sh python manage.py test

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM python:3.6-alpine
2+
3+
LABEL maintainer="whirish <[email protected]>"
4+
5+
ENV PYTHONUNBUFFERED 1
6+
7+
RUN sed -i -e 's/v3\.7/edge/g' /etc/apk/repositories && \
8+
apk upgrade --update-cache --available
9+
10+
RUN apk update && \
11+
apk add --virtual build-deps gcc python3-dev musl-dev libffi-dev && \
12+
apk add postgresql-dev && \
13+
apk add --no-cache --virtual .build-deps-testing \
14+
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
15+
gdal-dev \
16+
geos-dev \
17+
proj4-dev
18+
19+
RUN mkdir /config
20+
COPY /config/requirements.txt /config/
21+
RUN pip install -r /config/requirements.txt
22+
RUN mkdir /src
23+
WORKDIR /src
24+
EXPOSE 80
25+
CMD ["/bin/ash", "./init.sh", "gunicorn chron.wsgi -b 0.0.0.0:80"]

Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# import config
2+
# You can change the default config with `make cnf="config_special.env" [command]`
3+
cnf ?= django.env
4+
include $(cnf)
5+
6+
# Documentation
7+
.PHONY: help
8+
9+
help: ## Displays this message
10+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
11+
12+
.DEFAULT_GOAL := help
13+
14+
# Docker tasks
15+
16+
build: ## Builds and tags containers
17+
docker-compose build
18+
19+
run: ## Builds, starts, and runs containers
20+
docker-compose up --build -d
21+
22+
stop: ## Stops running containers
23+
docker-compose stop
24+
25+
clean: ## Stop and remove containers, networks, volmes, and images
26+
docker-compose down
27+
28+
# Debug tools
29+
run_debug: ## Builds, starts, and runs containers, running the built-in Django web server
30+
docker-compose run --service-ports web sh init.sh python manage.py runserver 0.0.0.0:81
31+
32+
exec_debug: ## Runs built-in Django web server
33+
docker-compose exec web python manage.py runserver 0.0.0.0:81
34+
35+
# Misc
36+
test: ## Builds, starts, and runs containers, running the django tests
37+
docker-compose run --service-ports web sh init.sh python manage.py test
38+
39+
exec_test: ## Executes django tests in a running container
40+
docker-compose exec web python manage.py test
41+
42+
exec_testk: ## Executes django tests in a running container, keeping the database schema from the previous test run
43+
docker-compose exec web python manage.py test -k
44+
45+
lint: ## Lints python files to pass CI
46+
docker-compose exec web black . --exclude /migrations/
47+
48+
bash: ## SSH into the docker container
49+
docker-compose exec web sh
50+
51+
shell: ## Open the django shell (https://django-extensions.readthedocs.io/en/latest/shell_plus.html)
52+
docker-compose exec web python manage.py shell_plus
53+
54+
dbshell: ## Open postgres
55+
docker-compose exec -u postgres db psql
56+
57+
admin: ## Creates a super user in the running `web` container based on the values supplied in the configuration file [NOT WORKING ATM]
58+
docker-compose exec web ./manage.py shell -c "from django.contrib.auth.models import User; User.objects.create_superuser('$(ADMIN_USER)', '$(ADMIN_EMAIL)', '$(ADMIN_PASS)')"

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Chron Backend
2+
3+
## Getting Started
4+
5+
```bash
6+
# Clone the repo
7+
git clone https://github.com/chronoscio/backend
8+
cd backend
9+
10+
# Create env files, remember to update accordingly
11+
cp django.env.sample django.env
12+
cp postgres.env.sample postgres.env
13+
14+
# Build and start the docker containers
15+
make run
16+
17+
# Navigate to http://localhost/
18+
# 502 error means postgres is starting, try again in a few seconds
19+
```

config/nginx/django.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
upstream web {
2+
ip_hash;
3+
server web:80;
4+
}
5+
6+
# portal
7+
server {
8+
location / {
9+
proxy_pass http://web/;
10+
}
11+
listen 80;
12+
server_name localhost;
13+
14+
location /static {
15+
autoindex on;
16+
alias /src/static/;
17+
}
18+
}

config/requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
black==18.9b0
2+
django-extensions==2.1.3
3+
Django==2.1.2
4+
gunicorn==19.7.0
5+
ipython==7.0.1
6+
psycopg2==2.7.4
7+
pylint-django==0.11.1
8+
pylint==1.8.4

django.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SECRET=dummy
2+
3+
ADMIN_USER=admin
4+
ADMIN_EMAIL=[email protected]
5+
ADMIN_PASS=p@55w0rd1

django.env.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SECRET=dummy
2+
3+
ADMIN_USER=admin
4+
5+
ADMIN_PASS=p@55w0rd1

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: '3'
2+
services:
3+
db:
4+
image: mdillon/postgis:10-alpine
5+
container_name: postgres01
6+
ports:
7+
- '5432'
8+
env_file:
9+
- postgres.env
10+
nginx:
11+
image: nginx:1.13-alpine
12+
container_name: nginx01
13+
ports:
14+
- '80:80'
15+
volumes:
16+
- ./project:/src
17+
- ./config/nginx:/etc/nginx/conf.d
18+
depends_on:
19+
- web
20+
web:
21+
build: .
22+
container_name: django01
23+
depends_on:
24+
- db
25+
volumes:
26+
- ./project:/src
27+
expose:
28+
- '80'
29+
ports:
30+
- '3500:3500'
31+
- '8006:81'
32+
env_file:
33+
- django.env
34+
restart: always

postgres.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POSTGRES_USER=postgres
2+
POSTGRES_DB=postgres
3+
POSTGRES_PASSWORD=postgres

postgres.env.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POSTGRES_USER=postgres
2+
POSTGRES_DB=postgres
3+
POSTGRES_PASSWORD=postgres

project/chron/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)