https://github.com/omarahm3/compat
Share docker-compose configuration between services
https://github.com/omarahm3/compat
docker docker-compose yaml
Last synced: 5 months ago
JSON representation
Share docker-compose configuration between services
- Host: GitHub
- URL: https://github.com/omarahm3/compat
- Owner: omarahm3
- Created: 2022-08-25T16:58:50.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-22T10:01:27.000Z (almost 4 years ago)
- Last Synced: 2024-11-15T00:50:13.325Z (over 1 year ago)
- Topics: docker, docker-compose, yaml
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compat
Have you ever wondered why there is no inheritance on docker-compose yaml syntax? and why am i writing the same stuff again and again for some services? well .. i had the same questions, and i couldn't find any solution for it, that is why i created this small tool to allow reusability on docker-compose files.
It is so simple as doing:
```
file: compat.yaml
version: '3.2'
services:
base_service:
deploy:
resources:
limits:
cpus: '0.1'
memory: 128M
reservations:
memory: 128M
mongo:
inherit: base_service
container_name: database
image: mongo
```
that will get converted into:
```
file: docker-compose.yaml
version: '3.2'
services:
mongo:
container_name: database
deploy:
resources:
limits:
cpus: '0.1'
memory: 128M
reservations:
memory: 128M
image: mongo
```
Or check [./example](./example) to know how to inherit multiple services.
## Why not `extends` though?
It depends on the use case, to use [extends](https://docs.docker.com/compose/extends) you must have a common "service" not "configuration" while for `inherit` you're just sharing configuration on whatever services.
## How?
Compat depends on a new file `compat.yaml` that is in the exact same syntax as `docker-compose.yaml` for only single purpose which is to allow the use of `compat` service property.
Running `compat` will actually parse the file by looking for `inherit` and for any `base_*` services, will reuse whatever under `base_*` and add them to services.
## Install
If you already have golang installed:
```
go install github.com/omarahm3/compat@latest
```
## TODO
- [X] Tests
- [X] Allow multiple inheritance?
- [ ] Add release workflow for automated releases