Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funkwerk/compose_format
format docker compose files using recipes from best practices
https://github.com/funkwerk/compose_format
compose docker docker-compose format
Last synced: 7 days ago
JSON representation
format docker compose files using recipes from best practices
- Host: GitHub
- URL: https://github.com/funkwerk/compose_format
- Owner: funkwerk
- License: mit
- Created: 2016-03-10T09:32:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-05T10:35:42.000Z (almost 5 years ago)
- Last Synced: 2024-11-01T06:42:25.166Z (14 days ago)
- Topics: compose, docker, docker-compose, format
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 45
- Watchers: 5
- Forks: 19
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/funkwerk/compose_format.svg)](https://travis-ci.org/funkwerk/compose_format)
[![](https://badge.imagelayers.io/funkwerk/compose_format.svg)](https://imagelayers.io/?images=funkwerk/compose_format:latest 'funkwerk/compose_format')
[![Docker Build](https://img.shields.io/docker/automated/funkwerk/compose_format.svg)](https://hub.docker.com/r/funkwerk/compose_format/)
[![PyPi version](https://img.shields.io/pypi/v/compose_format.svg)](https://pypi.python.org/pypi/compose_format/)
[![Docker pulls](https://img.shields.io/docker/pulls/funkwerk/compose_format.svg)](https://hub.docker.com/r/funkwerk/compose_format/)# compose_format
Formats docker-compose files by using the distilled docker compose best practices.
## Docker Compose Files are complex
Docker Compose Files could be rather complex.
If these files are complex, there are multiple ways to write the same thing.
If there are multiple ways to format these files, these multiple ways will be used.
Means that it will be not possible to diff your files, cause everybody writes them a bit different.## Alphabetical order vs. custom order
Sorting would be easy, if everything could be sorted alphabetically.
But in compose files the first thing mentioned for a service is the `image`.
`compose_format` aims to distill these compose format best practices into a tool.## Comments
Usually formatting tools destroy comments. But comments contain valueable TODO-markers or other hints.
`compose_format` putted effort into supporting comments.## Support
Note that this small utility is just valid until docker-compose has itself a format functionality.
Currently docker-compose just support the "config" switch. Which joins multiple compose files and print them in a machine-readable form.## Usage
### Via Python
Install it via:
`pip3 install compose_format`After that use it like
`compose_format compose-format.yml`
this will print the formatted compose file to stdout.
To let it replace the compose file add `--replace`.### Via Docker
Use it like:
`cat docker-compose.yml | docker run -i funkwerk/compose_format`## Features
- Support for Version 3, 2.1, 2, and 1.
- Support for Comments
- Orders Services, Volumes, Networks
- Orders Definitions
- Orders Port and Volume Lists## Contribution
Feel free to add issues or provide Pull Requests.
Especially when the order in some points violates the best practices.
This tool should be changed based on the evolving best practices.