Skip to content

Commit

Permalink
7 Add prefix and suffix (#8)
Browse files Browse the repository at this point in the history
* 7 Add prefix and suffix

* Fix lints

* Fix lints

* fix lints

* Adjust examples and add logo

* Add workflow_dispatch

* Fix lints
  • Loading branch information
veerendra2 authored Nov 30, 2024
1 parent a1a3b8c commit 82d9692
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 131 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ name: Release
on:
release:
types: [created]
workflow_dispatch:
inputs:
blog:
description: "Release Manually"
required: true
default: "yes"

jobs:
deploy:
publish:
name: Publish PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +33,7 @@ jobs:
twine upload --repository pypi dist/*
docker-build:
name: Docker Build
name: Docker Build & Push
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
Expand Down
56 changes: 41 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
# Kompozit

> :construction_worker: This tool is currently in beta and still under development!
![Docker Pulls](https://img.shields.io/docker/pulls/veerendra2/kompozit) ![PyPI - Status](https://img.shields.io/pypi/status/kompozit) ![PyPI - Version](https://img.shields.io/pypi/v/kompozit) [![Release](https://github.com/veerendra2/kompozit/actions/workflows/release.yml/badge.svg)](https://github.com/veerendra2/kompozit/actions/workflows/release.yml)

> 🚧 This tool is currently under development!
Declarative Configuration Management Tool for Docker Compose.

_Like [`kustomize`](https://kustomize.io/), but for [Docker Compose](https://docs.docker.com/compose/)._
_Like [`kustomize.io`](https://kustomize.io/), but for [Docker Compose](https://docs.docker.com/compose/)._

<p align="center">
<img alt="kompozit logo", width="150" src="https://i.postimg.cc/cH1dYN6f/komposeit.png">
</p>

## Features

Kompozit provides flexible, declarative overlays to manage complex Docker Compose configurations with support for:
Kompozit simplifies complex Docker Compose setups using declarative overlays, supporting:

- **[`patchesJSON6902`](https://datatracker.ietf.org/doc/html/rfc6902)**: JSON Merge Patch for precise modifications.
- **[`patchesStrategicMerge`](https://stackoverflow.com/q/71165168/2200798)**: Strategic Merge Patch for hierarchical changes.
- **[`patchesJSON6902`](https://datatracker.ietf.org/doc/html/rfc6902)**: Precise modifications with JSON Merge Patch.
- **[`patchesStrategicMerge`](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/strategic-merge-patch.md)**: Flexible hierarchical changes with Strategic Merge Patch.

## But Why...? :thinking:
## Resources

- 📖 [Documentation](https://veerendra2.gitbook.io/kompozit)
- 🛠️ [Examples](https://github.com/veerendra2/kompozit/tree/main/examples)

## But Why...? 🤔

There are scenarios where you might need different Docker Compose configurations for the same application on different machines.

Expand All @@ -21,18 +34,14 @@ Additionally, kompozit allows you to combine multiple `docker-compose.yml` files

- For instance, you can keep a generic `docker-compose.yml` for PostgreSQL in a central location and customize it for different stacks in other locations as needed.

## Installation :computer:
## Installation 💻

```bash
python -m pip install kompozit
```
### PyPi

## Usage :gear:
> [https://pypi.org/project/kompozit/](https://pypi.org/project/kompozit/)
```bash
git clone [email protected]:veerendra2/kompozit.git
cd kompozit
python -m pip install .
python -m pip install kompozit

kompozit --help
usage: kompozit [-h] [-b BUILD_PATH] [-o OUTPUT_DIR] [-v]
Expand All @@ -46,15 +55,32 @@ options:
-o, --output-dir OUTPUT_DIR
Directory to save the generated Docker Compose files. (default: None)
-v, --version Show kompozit version
```

### Docker

> [https://hub.docker.com/r/veerendra2/kompozit](https://hub.docker.com/r/veerendra2/kompozit)
```bash
docker pull veerendra2/kompozit
```

## Usage ⚙️

```bash
git clone [email protected]:veerendra2/kompozit.git
cd kompozit
python -m pip install .

kompozit --build ./examples/overlay
...

# inside docker
docker pull kompozit:latest
docker run -it --rm -v ./examples:/examples kompozit:latest -b /examples/overlay
```

## Local Development :wrench:
## Local Development 🔧

```bash
git clone [email protected]:veerendra2/kompozit.git
Expand Down
71 changes: 27 additions & 44 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,47 @@
# Example

[Docs](https://veerendra2.gitbook.io/kompozit)

```bash
$ python3 -m pip install kompozit
$ kompozit -b examples/overlay/
python3 -m pip install kompozit

kompozit -b examples/overlay/homeserver/
---
networks:
db:
public:
attachable: true
services:
postgres:
container_name: postgres
hostname: postgres
image: postgres:14-alpine
labels:
- com.centurylinklabs.watchtower.enable=false
- traefik.enable=false
networks:
- db
restart: always
volumes:
- acme:/var/lib/postgresql/data:rw
volumes:
acme: null
---
networks:
internal: false
private:
attachable: true
internal: true
public:
attachable: true
internal: false
volumes:
acme: null
services:
traefik:
command:
- NO_COMMAND_TEST
dev-traefik-test:
image: traefik:v2
hostname: traefik
container_name: traefik
restart: unless-stopped
environment:
CLOUDFLARE_DNS_API_TOKEN: ${CLOUDFLARE_DNS_API_TOKEN}
DUCKDNS_TOKEN: ${DUCKDNS_TOKEN}
hostname: traefik
image: traefik:v2
labels:
- com.centurylinklabs.watchtower.enable=true
- traefik.enable=true
- traefik.docker.network=traefik_public
- traefik.http.routers.api.tls=true
- traefik.http.routers.api.entryPoints=websecure
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.api.tls.certresolver=letsencrypt
- traefik.http.routers.api.rule=Host(`${MY_DOMAIN}`)
networks:
- public
- private
CLOUDFLARE_DNS_API_TOKEN: ${CLOUDFLARE_DNS_API_TOKEN}
ports:
- 80:80/tcp
- 443:443/tcp
restart: unless-stopped
networks:
- public
- private
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- acme:/letsencrypt
volumes:
acme: null
command:
- --log.level=INFO
- --api.insecure=false
- --api.dashboard=false
- --providers.docker=true
- --providers.docker.exposedByDefault=false
- --global.sendAnonymousUsage=false
- --global.checkNewVersion=false
labels:
- com.centurylinklabs.watchtower.enable=true
```
44 changes: 0 additions & 44 deletions examples/base/docker-compose-traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,6 @@ services:
hostname: traefik
container_name: traefik
restart: unless-stopped
command:
- "--log.level=INFO"
- "--api.insecure=false"
- "--api.dashboard=false"
- "--providers.docker=true"
- "--providers.docker.exposedByDefault=false"
- "--global.sendAnonymousUsage=false"
- "--global.checkNewVersion=false"
# ---------------------------------- ACME --------------------------------------------
- "--certificatesresolvers.letsencrypt.acme.dnschallenge=true"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.delaybeforecheck=5"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.provider=${MY_PROVIDER}"
- "[email protected]"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.disablePropagationCheck=true"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.resolvers=1.1.1.1:53,8.8.8.8:53"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
# -------------------------------- ENTRYPOINT -----------------------------------------
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entrypoints.websecure.address=:443"
# -------------------------------- PROXY -----------------------------------------
- "--entryPoints.web.forwardedHeaders.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.web.proxyProtocol.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.websecure.proxyProtocol.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.web.forwardedHeaders.insecure=false"
- "--entryPoints.web.proxyProtocol.insecure=false"
- "--entryPoints.websecure.forwardedHeaders.insecure=false"
- "--entryPoints.websecure.proxyProtocol.insecure=false"
# -------------------------------- PLUGINS -----------------------------------------
- --experimental.plugins.fail2ban.modulename=github.com/juitde/traefik-plugin-fail2ban
- --experimental.plugins.fail2ban.version=v0.2.0
- --experimental.plugins.fail2ban.modulename=github.com/Paxxs/traefik-get-real-ip
- --experimental.plugins.fail2ban.version=v1.0.2
labels:
- com.centurylinklabs.watchtower.enable=true
- traefik.enable=true
- traefik.docker.network=traefik_public
- traefik.http.routers.api.tls=true
- traefik.http.routers.api.entryPoints=websecure
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.api.tls.certresolver=letsencrypt
- traefik.http.routers.api.rule=Host(`${MY_DOMAIN}`)
environment:
DUCKDNS_TOKEN: "${DUCKDNS_TOKEN}"
CLOUDFLARE_DNS_API_TOKEN: "${CLOUDFLARE_DNS_API_TOKEN}"
Expand Down
2 changes: 0 additions & 2 deletions examples/base/kompozition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
resources:
- docker-compose-pg.yml
- docker-compose-traefik.yml
namePrefix: ggg-
nameSufix: -veer
4 changes: 0 additions & 4 deletions examples/overlay/docker-compose-traefik-patch.yml

This file was deleted.

12 changes: 12 additions & 0 deletions examples/overlay/homeserver/docker-compose-traefik-patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
traefik:
command:
- "--log.level=INFO"
- "--api.insecure=false"
- "--api.dashboard=false"
- "--providers.docker=true"
- "--providers.docker.exposedByDefault=false"
- "--global.sendAnonymousUsage=false"
- "--global.checkNewVersion=false"
labels:
- com.centurylinklabs.watchtower.enable=true
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
resources:
- ../base
- ../../base

namePrefix: dev-
nameSufix: -test
nameSuffix: -test

patchesStrategicMerge:
- path: docker-compose-traefik-patch.yml
Expand Down
46 changes: 46 additions & 0 deletions examples/overlay/public_wordpress/docker-compose-traefik-patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
services:
traefik:
command:
- "--log.level=INFO"
- "--api.insecure=false"
- "--api.dashboard=false"
- "--providers.docker=true"
- "--providers.docker.exposedByDefault=false"
- "--global.sendAnonymousUsage=false"
- "--global.checkNewVersion=false"
# ---------------------------------- ACME --------------------------------------------
- "--certificatesresolvers.letsencrypt.acme.dnschallenge=true"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.delaybeforecheck=5"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.provider=${MY_PROVIDER}"
- "[email protected]"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.disablePropagationCheck=true"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.resolvers=1.1.1.1:53,8.8.8.8:53"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
# -------------------------------- ENTRYPOINT -----------------------------------------
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entrypoints.websecure.address=:443"
# -------------------------------- PROXY -----------------------------------------
- "--entryPoints.web.forwardedHeaders.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.web.proxyProtocol.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.websecure.proxyProtocol.trustedIPs=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
- "--entryPoints.web.forwardedHeaders.insecure=false"
- "--entryPoints.web.proxyProtocol.insecure=false"
- "--entryPoints.websecure.forwardedHeaders.insecure=false"
- "--entryPoints.websecure.proxyProtocol.insecure=false"
# -------------------------------- PLUGINS -----------------------------------------
- --experimental.plugins.fail2ban.modulename=github.com/juitde/traefik-plugin-fail2ban
- --experimental.plugins.fail2ban.version=v0.2.0
- --experimental.plugins.fail2ban.modulename=github.com/Paxxs/traefik-get-real-ip
- --experimental.plugins.fail2ban.version=v1.0.2
labels:
- com.centurylinklabs.watchtower.enable=true
- traefik.enable=true
- traefik.docker.network=traefik_public
- traefik.http.routers.api.tls=true
- traefik.http.routers.api.entryPoints=websecure
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.api.tls.certresolver=letsencrypt
- traefik.http.routers.api.rule=Host(`${MY_DOMAIN}`)
15 changes: 15 additions & 0 deletions examples/overlay/public_wordpress/kompozition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
resources:
- ../../base

namePrefix: dev-
nameSuffix: -test

patchesStrategicMerge:
- path: docker-compose-traefik-patch.yml

patchesJSON6902:
- patch:
- op: replace
path: /services/traefik/image
value: "traefik:v2"
Loading

0 comments on commit 82d9692

Please sign in to comment.