mirror of
https://gitlab.sectorq.eu/home/docker-compose.git
synced 2025-12-14 10:24:53 +01:00
build
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
networks:
|
||||||
|
pihole:
|
||||||
|
driver: overlay
|
||||||
|
attachable: true
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: 192.168.78.0/24
|
||||||
|
driver: default
|
||||||
services:
|
services:
|
||||||
pihole:
|
pihole:
|
||||||
cap_add:
|
cap_add:
|
||||||
@@ -11,13 +19,25 @@ services:
|
|||||||
TZ: Europe/Bratislava
|
TZ: Europe/Bratislava
|
||||||
hostname: m-server
|
hostname: m-server
|
||||||
image: pihole/pihole:latest
|
image: pihole/pihole:latest
|
||||||
|
networks:
|
||||||
|
pihole:
|
||||||
|
ipv4_address: 192.168.78.254
|
||||||
ports:
|
ports:
|
||||||
- 53:53
|
- target: 53
|
||||||
- 9380:80
|
published: 53
|
||||||
- 9343:443
|
protocol: udp
|
||||||
|
mode: ingress
|
||||||
|
- target: 80
|
||||||
|
published: 9380
|
||||||
|
protocol: tcp
|
||||||
|
mode: ingress
|
||||||
|
- target: 443
|
||||||
|
published: 9343
|
||||||
|
protocol: tcp
|
||||||
|
mode: ingress
|
||||||
volumes:
|
volumes:
|
||||||
- pihole-etc:/etc/pihole
|
- /share/docker_data/pihole/etc-pihole:/etc/pihole
|
||||||
- pihole-dnsmasq.d:/etc/dnsmasq.d
|
- /share/docker_data/pihole/etc-dnsmasq.d:/etc/dnsmasq.d
|
||||||
deploy:
|
deploy:
|
||||||
labels:
|
labels:
|
||||||
com.centurylinklabs.watchtower.enable: 'true'
|
com.centurylinklabs.watchtower.enable: 'true'
|
||||||
@@ -39,6 +59,3 @@ services:
|
|||||||
placement:
|
placement:
|
||||||
constraints:
|
constraints:
|
||||||
- node.role == manager
|
- node.role == manager
|
||||||
volumes:
|
|
||||||
pihole-etc:
|
|
||||||
pihole-dnsmasq.d:
|
|
||||||
@@ -53,9 +53,9 @@ services:
|
|||||||
pihole:
|
pihole:
|
||||||
ipv4_address: 192.168.78.254
|
ipv4_address: 192.168.78.254
|
||||||
ports:
|
ports:
|
||||||
- 53:53
|
- '53:53'
|
||||||
- 9380:80
|
- '9380:80'
|
||||||
- 9343:443
|
- '9343:443'
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- /share/docker_data/pihole/etc-pihole:/etc/pihole
|
- /share/docker_data/pihole/etc-pihole:/etc/pihole
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ def convert_service(service):
|
|||||||
for key, value in service.items():
|
for key, value in service.items():
|
||||||
#print(key, value)
|
#print(key, value)
|
||||||
# Unsupported in Swarm
|
# Unsupported in Swarm
|
||||||
if key in ["container_name", "restart", "depends_on"]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Move labels → deploy.labels
|
# Move labels → deploy.labels
|
||||||
#print(f"Labels: {deploy_section['labels']}")
|
#print(f"Labels: {deploy_section['labels']}")
|
||||||
@@ -46,11 +45,15 @@ def convert_service(service):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
swarm_service[key] = value
|
swarm_service[key] = value
|
||||||
# for en in swarm_service['environment']:
|
envir = []
|
||||||
# #print(f"Environment Variable: {en} : {swarm_service['environment'][en]}")
|
for en in swarm_service['environment']:
|
||||||
# print(en)
|
#print(f"Environment Variable: {en} : {swarm_service['environment'][en]}")
|
||||||
# print(swarm_service['environment'][en])
|
if "=" in en:
|
||||||
# swarm_service['environment'][en] = str(swarm_service['environment'][en]).lower()
|
e = en.split("=",1)[0]
|
||||||
|
envir.append(e)
|
||||||
|
print(en)
|
||||||
|
print(swarm_service['environment'][en])
|
||||||
|
swarm_service['environment'].appeendstr(swarm_service['environment'][en]).lower()
|
||||||
#print("Deploy Section:")
|
#print("Deploy Section:")
|
||||||
#print(swarm_service)
|
#print(swarm_service)
|
||||||
# Merge user deploy section if present
|
# Merge user deploy section if present
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ OUTPUT_FILE = f"__swarm/{stack_name}/{stack_name}-swarm.yml"
|
|||||||
def convert_ports(ports):
|
def convert_ports(ports):
|
||||||
"""Convert short port syntax to Swarm long syntax."""
|
"""Convert short port syntax to Swarm long syntax."""
|
||||||
result = []
|
result = []
|
||||||
|
print(f"Converting ports: {ports}")
|
||||||
for p in ports:
|
for p in ports:
|
||||||
|
print(f"Port entry: {p}")
|
||||||
if isinstance(p, str):
|
if isinstance(p, str):
|
||||||
# format: "8080:80"
|
# format: "8080:80"
|
||||||
pub, tgt = p.split(":")
|
pub, tgt = p.split(":")
|
||||||
@@ -45,9 +47,15 @@ def ensure_labels_as_string(labels):
|
|||||||
|
|
||||||
def convert_compose_to_swarm(data):
|
def convert_compose_to_swarm(data):
|
||||||
services = data.get("services", {})
|
services = data.get("services", {})
|
||||||
|
input(services)
|
||||||
for name, svc in services.items():
|
for name, svc in services.items():
|
||||||
|
print(f"Converting service: {name} , svc: {svc}")
|
||||||
|
if name in ["container_name", "restart", "depends_on"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
svc.pop('restart', None)
|
||||||
|
svc.pop('depends_on', None)
|
||||||
|
svc.pop('container_name', None)
|
||||||
# 1) Convert environment list → dict (strings)
|
# 1) Convert environment list → dict (strings)
|
||||||
if "environment" in svc and isinstance(svc["environment"], list):
|
if "environment" in svc and isinstance(svc["environment"], list):
|
||||||
svc["environment"] = env_list_to_dict(svc["environment"])
|
svc["environment"] = env_list_to_dict(svc["environment"])
|
||||||
@@ -77,6 +85,7 @@ def convert_compose_to_swarm(data):
|
|||||||
|
|
||||||
# 6) Convert ports to long format
|
# 6) Convert ports to long format
|
||||||
if "ports" in svc:
|
if "ports" in svc:
|
||||||
|
input(svc)
|
||||||
svc["ports"] = convert_ports(svc["ports"])
|
svc["ports"] = convert_ports(svc["ports"])
|
||||||
|
|
||||||
# 7) Remove container_name (not allowed in Swarm)
|
# 7) Remove container_name (not allowed in Swarm)
|
||||||
@@ -87,7 +96,7 @@ def convert_compose_to_swarm(data):
|
|||||||
def main():
|
def main():
|
||||||
with open(INPUT_FILE, "r") as f:
|
with open(INPUT_FILE, "r") as f:
|
||||||
compose = yaml.safe_load(f)
|
compose = yaml.safe_load(f)
|
||||||
|
input(compose)
|
||||||
swarm = convert_compose_to_swarm(compose)
|
swarm = convert_compose_to_swarm(compose)
|
||||||
|
|
||||||
with open(OUTPUT_FILE, "w") as f:
|
with open(OUTPUT_FILE, "w") as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user