59 lines
2.3 KiB
Markdown
Raw Normal View History

2022-06-04 02:12:47 +00:00
# py-cookiecutter-templates
Project directory structure templates for the Python Cookiecutter package.
## What's Cookiecutter?
The Python package [Cookiecutter](https://github.com/cookiecutter/cookiecutter) assists in creating directory structure for whatever purpose you need such as for example a new Python project, an Ansible role or a `docker-compose` project - anything really that benefits from a unifirm reproducible directory structure. If you've ever wanted to put project structure best practices into version control then Cookiecutter's here to help.
Cookiecutter is governed by so-called Cookiecutter templates, most of its magic inside Cookiecutter templates happens via the [Jinja2 template engine](https://palletsprojects.com/p/jinja/). You'll feel right at home if you're familiar with Ansible.
## Repo layout
Each subdirectory in this repo is a Cookiecutter template, you'll recognize them from their telltale `cookiecutter.json` files. Directories usually also have a readme file explaining more about each individual template.
## Get started
Get Cookiecutter like so:
```
pip install cookiecutter
```
Execute a template like so, `docker-compose` as an example:
```
cookiecutter https://quico.space/Quico/py-cookiecutter-templates.git --directory 'docker-compose'
```
Cookiecutter prompts you for whatever info the template needs then generates files and directories.
This is Cookiecutter prompting for info:
```
service []: grafana
component_list [grafana]: grafana,nginx
context []: cncf
```
The end result is a directory structure that has everything you need to hit the ground running.
```
.
└── grafana
├── build-context
│   ├── grafana
│   │   ├── docker-data
│   │   │   └── .gitkeep
│   │   ├── Dockerfile
│   │   └── extras
│   │   └── .gitkeep
│   └── nginx
│   ├── docker-data
│   │   └── .gitkeep
│   ├── Dockerfile
│   └── extras
│   └── .gitkeep
├── common-settings.yml
├── docker-compose.override.yml
├── docker-compose.yml
└── env
└── fully.qualified.domain.name.example
```