Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Database config
POSTGRES_DB=backend
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_PORT=5432
POSTGRES_HOST=db

# Django config
DJANGO_SECRET_KEY=4y7c-7+bja2@e1$%d@6v+#dir%70!dc7!7_04e2r(d%4$g7+id
DJANGO_HASHID_FIELD_SALT='9q#3t$5gs9ob682b@(6^fdv2kg*0ztr(3doa((w&kyq!d8rbt^'
DJANGO_SETTINGS_MODULE=settings.configs
DJANGO_ALLOWED_HOSTS=localhost
DJANGO_DEBUG=False
DJANGO_CONFIGURATION=Prod
DJANGO_ADMIN_URL=admin
15 changes: 15 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Database config
POSTGRES_DB=backend
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_PORT=5432
POSTGRES_HOST=db

# Django config
DJANGO_SECRET_KEY=4y7c-7+bja2@e1$%d@6v+#dir%70!dc7!7_04e2r(d%4$g7+id
DJANGO_HASHID_FIELD_SALT='9q#3t$5gs9ob682b@(6^fdv2kg*0ztr(3doa((w&kyq!d8rbt^'
DJANGO_SETTINGS_MODULE=settings.configs
DJANGO_ALLOWED_HOSTS=localhost
DJANGO_DEBUG=False
DJANGO_CONFIGURATION=Local
DJANGO_ADMIN_URL=admin
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
db.sqlite3
.env
.idea/
__pycache__/
*.py[cod]
.idea/
db.sqlite3
.pytest_cache/
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
sudo: required
services:
- docker
language: python
python:
- "3.6"
install:
- pip install -r requirements_test.txt
before_install:
- docker-compose -v
- docker -v
script:
- pytest
- docker-compose run --rm backend scripts/run_test.sh
- docker-compose run --rm backend python manage.py makemigrations --dry-run --check || { echo "ERROR Migration listed above have not been created"; exit 1; }
notifications:
email:
on_success: change
on_failure: always
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3"

services:
backend:
build:
context: .
dockerfile: src/Dockerfile
args:
- ENV_NAME=local
env_file:
- .env
depends_on:
- db
ports:
- "8000:8000"
command: scripts/run_local.sh
volumes:
- ./src:/app/backend
db:
image: postgres:10.3-alpine
env_file:
- .env
3 changes: 0 additions & 3 deletions pytest.ini

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

7 changes: 7 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Django==2.0.2
django-configurations==2.0
django-hashid-field==2.1.0
djangorestframework==3.7.7
djangorestframework-jwt==1.11.0
dj_database_url==0.5.0
psycopg2==2.7.4
4 changes: 4 additions & 0 deletions requirements/local.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r base.txt
-r prod.txt
-r qa.txt
-r test.txt
2 changes: 2 additions & 0 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r base.txt
uwsgi==2.0.17
2 changes: 2 additions & 0 deletions requirements/qa.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r base.txt
uwsgi==2.0.17
8 changes: 8 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-r base.txt
factory-boy==2.10.0
flake8==3.5.0
pytest==3.4.1
pytest-django==3.1.2
pytest-env==0.6.2
pytest-factoryboy==2.0.1
pytest-sugar==0.9.1
5 changes: 0 additions & 5 deletions requirements_test.txt

This file was deleted.

140 changes: 0 additions & 140 deletions restauth/settings.py

This file was deleted.

20 changes: 0 additions & 20 deletions restauth/tests/factories.py

This file was deleted.

23 changes: 23 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.6-alpine

ENV APP_DIR /app/backend

RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR

RUN apk update && \
apk add postgresql-libs && \
apk add --virtual .build-deps build-base gcc linux-headers make python3-dev musl-dev postgresql-dev

# Available choices: base, prod, qa, test, local
ARG ENV_NAME

COPY requirements $APP_DIR/requirements
RUN pip install --no-cache-dir -r requirements/${ENV_NAME}.txt && \
apk --purge del .build-deps

COPY src $APP_DIR

ENTRYPOINT ["sh", "/app/backend/scripts/entrypoint.sh"]

EXPOSE 8000
5 changes: 3 additions & 2 deletions manage.py → src/manage.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "restauth.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.configs")
os.environ.setdefault('DJANGO_CONFIGURATION', 'Prod')
try:
from django.core.management import execute_from_command_line
from configurations.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
Expand Down
5 changes: 5 additions & 0 deletions src/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
python_files = tests.py test_*.py *_tests.py
env =
DJANGO_SETTINGS_MODULE = settings.configs
DJANGO_CONFIGURATION = Test
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions restauth/apps.py → src/restauth/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

class RestauthConfig(AppConfig):
name = 'restauth'
verbose_name = 'Rest Auth'
File renamed without changes.
24 changes: 24 additions & 0 deletions src/restauth/migrations/0003_auto_20180304_1017.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.0.2 on 2018-03-04 10:17

from django.db import migrations, models
import hashid_field.field


class Migration(migrations.Migration):

dependencies = [
('restauth', '0002_userprofile'),
]

operations = [
migrations.AlterField(
model_name='user',
name='id',
field=hashid_field.field.HashidAutoField(alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', min_length=7, primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='user',
name='is_active',
field=models.BooleanField(default=True),
),
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading