Skip to content

Commit

Permalink
Merge pull request #36 from CheesecakeLabs/bernardo/pipenv-to-pip
Browse files Browse the repository at this point in the history
Change dependency manager back to pip + requirements file
  • Loading branch information
smaniotto authored Jun 13, 2019
2 parents ccd3594 + 01c5d47 commit 01e9956
Show file tree
Hide file tree
Showing 74 changed files with 288 additions and 1,097 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.6-jessie
FROM python:3.7-alpine

RUN apk update && apk add build-base postgresql-dev

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app

RUN pip install --upgrade pip pipenv
RUN set -ex && pipenv install --deploy --system
RUN pip install -r requirements.txt

ENTRYPOINT ["sh", "docker-entrypoint.sh"]
19 changes: 0 additions & 19 deletions Pipfile

This file was deleted.

224 changes: 0 additions & 224 deletions Pipfile.lock

This file was deleted.

25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<img src="https://s3-us-west-2.amazonaws.com/ckl-generic-hosting/cheesecake-logo-blue.png" height="60">

# django-drf-boilerplate
# Django DRF Boilerplate
Boilerplate project using Django and Django REST Framework.
Currently supporting only Python 3.x.

**IMPORTANT**:
Make sure you have Django 2.0 installed on your environment.
Docker Compose is used *just* for development environment. The Dockerfile works without it.

## How to install
## How to install with Pyenv

```bash
$ pyenv virtualenv 3.7.3 <project_name>
$ pyenv activate <project_name>
$ pip install Django==2.2.2
$ django-admin.py startproject \
--template=https://github.com/CheesecakeLabs/django-drf-boilerplate/archive/master.zip \
<project_name> .
$ pip install -r requirements.txt
$ pip install -r requirements/dev.txt
$ python src/manage.py runserver
```

Expand All @@ -27,19 +29,12 @@ $ django-admin.py startproject \
$ docker-compose up
```

## Install git pre-commit hook
Check code syntax and style before commit changes.
## Install Black code formatter to your editor
Check code syntax and style before committing changes.

After initializing git, add flake8 hook.
Or run it manually:
```bash
$ git init
$ python -m flake8 --install-hook git
```

Set flake8 strict parameter to true, this forces all violations to be fixed
before the commit.
```bash
$ git config --bool flake8.strict true
$ black .
```

## Database
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
ENV: development

db:
image: postgres:9.6.6
image: postgres:11
ports:
- 5432:5432
volumes:
Expand Down
6 changes: 2 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/bin/bash
set -e

if [ "$ENV" = "development" ] || [ "$ENV" = "staging" ] ; then
pipenv install --dev --system
if [ "$ENV" = "development" ] ; then
python docker/web/check_db.py --service-name postgres --ip db --port 5432
fi

if [ "$1" = "manage" ]; then
shift 1
exec python src/manage.py "$@"
else
python docker/web/check_db.py --service-name Postgres --ip db --port 5432

python src/manage.py migrate # Apply database migrations
python src/manage.py collectstatic --noinput # Collect static files

Expand Down
12 changes: 7 additions & 5 deletions docker/web/check_db.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import socket
import time
import argparse

""" Check if port is open, avoid docker-compose race condition """

parser = argparse.ArgumentParser(description='Check if port is open, avoid\
docker-compose race condition')
parser.add_argument('--service-name', required=True)
parser.add_argument('--ip', required=True)
parser.add_argument('--port', required=True)
parser = argparse.ArgumentParser(
description="Check if port is open, avoid docker-compose race condition"
)
parser.add_argument("--service-name", required=True)
parser.add_argument("--ip", required=True)
parser.add_argument("--port", required=True)

args = parser.parse_args()

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-r requirements/base.txt
15 changes: 15 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Django
Django==2.2.2
django-environ==0.4.5

# Auth
cklauth==0.4.0

# Database
psycopg2==2.8.2

# Static files
whitenoise==4.1.2

# Webserver
gunicorn==19.9.0
3 changes: 3 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r base.txt

black==19.3b0
Loading

0 comments on commit 01e9956

Please sign in to comment.