75 lines
3.0 KiB
Markdown
Raw Normal View History

# docker-compose template
## Run it
Execute this template like so:
```
cookiecutter https://quico.space/Quico/py-cookiecutter-templates.git --directory 'docker-compose'
```
Cookiecutter interactively prompts you for the following info, here with example answers:
```
service []: grafana
component_list [grafana]: grafana,nginx
context []: cncf
```
Done, directory structure and files for your next `docker-compose` project are ready for you to hit the ground running.
## Explanation and terminology
Each `docker-compose` project forms a *__service__* that may consist of either a single or multiple *__components__*.
The `service` variable by default is empty. In this example we've chosen to name the service `grafana`. We want `grafana` to consist of two components, namely Grafana itself and Nginx. Syntax for a multi-component `component_list` is a comma-separated list without spaces. The string `grafana,nginx` will be treated as a list of two components. Capitalization doesn't matter, we're lowercasing all strings automatically. The template prefills `component_list` with whatever you previously entered as the `service` name. To create directory structure for a _single-component service_ confirm the default. If `component_list` and `service` are identical directory structure will be that for a _single-component service_.
The last prompt for a *__context__* is a generic string to help you distinguish deployments. It can be whatever you want such as for example a team name, here `cncf`.
## Result
### Multi-component service
Above example of a multi-component (two in this case) `grafana` service will give you this directory structure:
```
.
└── 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
```
2022-06-05 00:29:10 +02:00
Check out file contents over in the [examples/grafana](examples/grafana) subdir.
2022-06-05 00:34:49 +02:00
### Single-component service
With an alternative single-component `hashicorpvault` service the result may look like this:
```
.
└── hashicorpvault
├── build-context
│   ├── docker-data
│   │   └── .gitkeep
│   ├── Dockerfile
│   └── extras
│   └── .gitkeep
├── common-settings.yml
├── docker-compose.override.yml
├── docker-compose.yml
└── env
└── fully.qualified.domain.name.example
```
Check out file contents over in the [examples/hashicorpvault](examples/hashicorpvault) subdir.