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