Cleanup Project Template

This commit is contained in:
BJ Dierkes 2018-07-29 13:03:00 -05:00
parent a1b3d44333
commit c54b378c62
14 changed files with 75 additions and 61 deletions

View File

@ -1,8 +1,9 @@
FROM python:3.6-alpine
MAINTAINER BJ Dierkes <derks@datafolklabs.com>
WORKDIR /app
COPY . /app
ENV PS1="\[\e[0;33m\]|> cement <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "
WORKDIR /src
COPY . /src
RUN python setup.py install \
&& rm -rf /app
&& rm -rf /src
WORKDIR /
ENTRYPOINT ["/usr/local/bin/cement"]

View File

@ -9,7 +9,7 @@ class Base(Controller):
class Meta:
label = 'base'
description = 'Cement Framework Developer Tools'
epilog = 'Example: cement generate app /path/to/myapp'
epilog = 'Example: cement generate project /path/to/myapp'
arguments = [
(['-v', '--version'], {'action': 'version', 'version': BANNER}),

View File

@ -0,0 +1,5 @@
# {{ name }} Change History
## 0.0.1
Initial release.

View File

@ -1,16 +1,18 @@
FROM python:3.6-alpine
MAINTAINER {{ creator }} <{{ creator_email }}>
WORKDIR /app
COPY . /app
ENV PS1="\[\e[0;33m\]|> {{ label }} <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "
WORKDIR /src
COPY . /src
RUN apk update && \
apk add git && \
pip install --no-cache-dir -r requirements.txt \
&& rm -f /usr/local/lib/python3.6/site-packages/cement.egg-link \
&& cd src/cement \
&& python setup.py install \
&& cd /app \
&& cd /src \
&& rm -rf src/cement \
&& python setup.py install
RUN rm -rf /app
RUN rm -rf /src
WORKDIR /
ENTRYPOINT ["{{ label }}"]

View File

@ -0,0 +1,31 @@
.PHONY: clean virtualenv test docker dist dist-upload
clean:
find . -name '*.py[co]' -delete
virtualenv:
virtualenv --prompt '|> {{ label }} <| ' env
env/bin/pip install -r requirements-dev.txt
env/bin/python setup.py develop
@echo
@echo "VirtualENV Setup Complete. Now run: source env/bin/activate"
@echo
test:
python -m pytest \
-v \
--cov={{ label }} \
--cov-report=term \
--cov-report=html:coverage-report \
tests/
docker: clean
docker build -t {{ label }}:latest .
dist: clean
rm -rf dist/*
python setup.py sdist
python setup.py bdist_wheel
dist-upload:
twine upload dist/*

View File

@ -10,28 +10,28 @@ $ pip install setup.py
## Development
This project includes a number of helpers in the `Makefile` to streamline common development tasks.
### Environment Setup
This project includes a basic Docker Compose configuration that will setup a local development environment with all dependencies, and services required for development and testing.
The following demonstrates setting up and working with a development environment:
```
$ make dev
[...]
|> {{ label }} <| app #
```
### create a virtualenv for development
The `{{ label }}` command line application is installed in `develop` mode, therefore all changes will be live and can be tested immediately as code is modified.
$ make virtualenv
```
|> {{ label }} <| app # {{ label }} --help
```
$ source env/bin/activate
### Running Tests
Execute tests from within the development environment:
### run {{ label }} cli application
```
|> {{ label }} <| app # make test
$ {{ label }} --help
### run pytest / coverage
$ make test
```
@ -66,20 +66,4 @@ and can be built with the included `make` helper:
$ make docker
$ docker run -it {{ label }} --help
usage: {{ label }} [-h] [--debug] [--quiet] [-o {json,yaml}] [-v] {command1} ...
{{ description }}
optional arguments:
-h, --help show this help message and exit
--debug toggle debug output
--quiet suppress all output
-o {json,yaml} output handler
-v, --version show program's version number and exit
sub-commands:
{command1}
command1 example sub command1
Usage: {{ title }} command1 --foo bar
```

View File

@ -1,14 +0,0 @@
version: "3"
services:
{{ label }}:
image: "{{ label }}:dev"
build:
context: .
dockerfile: Dockerfile
hostname: {{ label }}
stdin_open: true
tty: true
working_dir: '/{{ label }}'
entrypoint: '/bin/ash'
volumes:
- ".:/{{ label }}"

View File

@ -0,0 +1,8 @@
-r requirements.txt
pytest
pytest-cov
coverage
twine>=1.11.0
setuptools>=38.6.0
wheel>=0.31.0

View File

@ -21,6 +21,7 @@ def tmp(request):
def __init__(self):
self.dir = mkdtemp()
_, self.file = mkstemp(dir=self.dir)
t = Tmp()
yield t

View File

@ -1,5 +0,0 @@
from .controllers.base import Base
def load(app):
app.handler.register(Base)

View File

@ -6,7 +6,7 @@ from .controllers.base import Base
# configuration defaults
DEFAULTS = init_defaults('{{ label }}')
DEFAULTS['{{ label }}']['{{ foo }}'] = 'bar'
DEFAULTS['{{ label }}']['foo'] = 'bar'
class {{ class_name }}(App):

View File

@ -9,7 +9,8 @@ services:
stdin_open: true
tty: true
volumes:
- ".:/app"
- '.:/src'
working_dir: '/src'
links:
- redis:redis
- memcached:memcached

View File

@ -2,8 +2,8 @@ FROM python:3.6-alpine
MAINTAINER BJ Dierkes <derks@datafolklabs.com>
ENV PS1="\[\e[0;33m\]|> cement <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "
WORKDIR /app
COPY requirements-dev.txt /app/
WORKDIR /src
COPY requirements-dev.txt /src/
RUN apk update \
&& apk add libmemcached-dev \
gcc \
@ -16,7 +16,7 @@ RUN apk update \
git \
&& ln -sf /usr/bin/vim /usr/bin/vi \
&& pip install --no-cache-dir -r requirements-dev.txt
COPY . /app
COPY . /src
COPY docker/vimrc /root/.vimrc
RUN python setup.py develop
CMD ["/bin/bash"]