Resources:
- Read the first part in https://github.com/valmy/pyramid-docker
- https://docs.pylonsproject.org/projects/pyramid/en/latest/quick_tour.html
Since cookiecutter's purpose is to generate the directory template for the actual application we run it on the host OS's pipenv without docker, and then use setup the environment for result in docker.
-
Setup env for cookiecutter
$ mkdir cookiecutter $ cd cookiecutter $ pipenv --three $ pipenv install cookiecutter
-
Run cookiecutter
$ pipenv run cookiecutter gh:Pylons/pyramid-cookiecutter-starter --checkout 1.10-branch
-
Use the generated folder as the root folder for the next section
Alternatively we can use docker CLI to run this without Python on the host OS:
$ docker run -it -v `pwd`:/app kennethreitz/pipenv
# pipenv --three
# pipenv install cookiecutter
# pipenv run cookiecutter gh:Pylons/pyramid-cookiecutter-starter --checkout 1.10-branch
-
Start with simple
docker-compose.yml
file:version: '3' services: webapp: image: kennethreitz/pipenv volumes: - .:/app - ./.local:/root/.local command: tail -f /dev/null
We mount our code folder to /app and
./.local
to store the virtualenv of our app -
Get the container up:
$ docker-compose up
-
From another shell, get into the container:
$ docker-compose exec webapp bash
-
Setup an env and install pyramid
# pipenv --three # pipenv install -e ".[testing]"
-
Get to the environment
# pipenv shell
-
Edit docker-compose.yml
version: '3' services: webapp: image: kennethreitz/pipenv volumes: - .:/app - ./.local:/root/.local ports: - 6543:6543 command: pipenv run pserve development.ini --reload
Edit in development.ini:
listen = localhost:6543
tolisten = 0.0.0.0:6543
Activate debugtoolbar:
debugtoolbar.hosts = 0.0.0.0/0
-
Run pytest:
docker-compose exec webapp pipenv run pytest --cov --cov-report=term-missing