This commit is contained in:
2025-11-30 17:12:46 +01:00
parent befd931165
commit 5ef7c025f4
3 changed files with 62 additions and 50 deletions

View File

@@ -1,8 +1,3 @@
volumes:
bookstack_db_data:
driver: local
bookstack_app_data:
driver: local
services: services:
app: app:
env_file: env_file:
@@ -14,7 +9,7 @@ services:
protocol: tcp protocol: tcp
mode: ingress mode: ingress
volumes: volumes:
- bookstack_app_data:/config - /share/docker_data/bookstack/bookstack_app_data:/config
deploy: deploy:
labels: labels:
com.centurylinklabs.watchtower.enable: 'true' com.centurylinklabs.watchtower.enable: 'true'
@@ -40,7 +35,7 @@ services:
PUID: 0 PUID: 0
image: ${DOCKER_REGISTRY:-}lscr.io/linuxserver/mariadb image: ${DOCKER_REGISTRY:-}lscr.io/linuxserver/mariadb
volumes: volumes:
- bookstack_db_data:/config - /share/docker_data/bookstack/bookstack_db_data:/config
deploy: deploy:
labels: labels:
wud.watch: 'true' wud.watch: 'true'
@@ -49,3 +44,4 @@ services:
placement: placement:
constraints: constraints:
- node.role == manager - node.role == manager
version: '2'

View File

@@ -1,16 +1,16 @@
PUID: 1000 PUID=1000
PGID: 1000 PGID=1000
APP_URL: https://bookstack.sectorq.eu APP_URL=https://bookstack.sectorq.eu
DB_HOST: db DB_HOST=db
DB_PORT: 3306 DB_PORT=3306
DB_USER: bookstack DB_USER=bookstack
DB_PASS: l4c1j4yd33Du5lo DB_PASS=l4c1j4yd33Du5lo
DB_DATABASE: bookstackapp DB_DATABASE=bookstackapp
MYSQL_ROOT_PASSWORD: l4c1j4yd33Du5lo MYSQL_ROOT_PASSWORD=l4c1j4yd33Du5lo
TZ: Europe/Bratislava TZ=Europe/Bratislava
MYSQL_DATABASE: bookstackapp MYSQL_DATABASE=bookstackapp
MYSQL_USER: bookstack MYSQL_USER=bookstack
MYSQL_PASSWORD: l4c1j4yd33Du5lo MYSQL_PASSWORD=l4c1j4yd33Du5lo
# # Set authentication method to be saml2 # # Set authentication method to be saml2
# AUTH_METHOD: saml2 # AUTH_METHOD: saml2
# # Control if BookStack automatically initiates login via your SAML system if it's the only authentication method. # # Control if BookStack automatically initiates login via your SAML system if it's the only authentication method.
@@ -46,41 +46,41 @@ MYSQL_PASSWORD: l4c1j4yd33Du5lo
# Set OIDC to be the authentication method # Set OIDC to be the authentication method
AUTH_METHOD: oidc AUTH_METHOD=oidc
#AUTH_METHOD: standard #AUTH_METHOD: standard
# Control if BookStack automatically initiates login via your OIDC system # Control if BookStack automatically initiates login via your OIDC system
# if it's the only authentication method. Prevents the need for the # if it's the only authentication method. Prevents the need for the
# user to click the "Login with x" button on the login page. # user to click the "Login with x" button on the login page.
# Setting this to true enables auto-initiation. # Setting this to true enables auto-initiation.
AUTH_AUTO_INITIATE: true AUTH_AUTO_INITIATE=true
# Set the display name to be shown on the login button. # Set the display name to be shown on the login button.
# (Login with <name>) # (Login with <name>)
OIDC_NAME: SSO OIDC_NAME=SSO
# Name of the claims(s) to use for the user's display name. # Name of the claims(s) to use for the user's display name.
# Can have multiple attributes listed, separated with a '|' in which # Can have multiple attributes listed, separated with a '|' in which
# case those values will be joined with a space. # case those values will be joined with a space.
# Example: OIDC_DISPLAY_NAME_CLAIMS=given_name|family_name # Example: OIDC_DISPLAY_NAME_CLAIMS=given_name|family_name
OIDC_DISPLAY_NAME_CLAIMS: name OIDC_DISPLAY_NAME_CLAIMS=name
# OAuth Client ID to access the identity provider # OAuth Client ID to access the identity provider
OIDC_CLIENT_ID: GCPj547vTmEpmsCM8jkuR222SS31yZMdp7oAU82U OIDC_CLIENT_ID=GCPj547vTmEpmsCM8jkuR222SS31yZMdp7oAU82U
# OAuth Client Secret to access the identity provider # OAuth Client Secret to access the identity provider
OIDC_CLIENT_SECRET: Nador7SOdsYgfNhRwbeRKLNPkPiASBAlTnKVi294xbOz8MM3e2RlzAaWQsQNZmBtLLZVifb1TG3OpKrVXeeW3Vu8HmJuvy8GwSAT2r0pP0241tDdEShq7UkP9G5Esdt8 OIDC_CLIENT_SECRET=Nador7SOdsYgfNhRwbeRKLNPkPiASBAlTnKVi294xbOz8MM3e2RlzAaWQsQNZmBtLLZVifb1TG3OpKrVXeeW3Vu8HmJuvy8GwSAT2r0pP0241tDdEShq7UkP9G5Esdt8
# Issuer URL # Issuer URL
# Must start with 'https://' # Must start with 'https://'
OIDC_ISSUER: https://auth.sectorq.eu/application/o/bookstack/ OIDC_ISSUER=https://auth.sectorq.eu/application/o/bookstack/
# The "end session" (RP-initiated logout) URL to call during BookStack logout. # The "end session" (RP-initiated logout) URL to call during BookStack logout.
# By default this is false which disables RP-initiated logout. # By default this is false which disables RP-initiated logout.
# Setting to "true" will enable logout if found as supported by auto-discovery. # Setting to "true" will enable logout if found as supported by auto-discovery.
# Otherwise, this can be set as a specific URL endpoint. # Otherwise, this can be set as a specific URL endpoint.
OIDC_END_SESSION_ENDPOINT: false OIDC_END_SESSION_ENDPOINT=false
# Enable auto-discovery of endpoints and token keys. # Enable auto-discovery of endpoints and token keys.
# As per the standard, expects the service to serve a # As per the standard, expects the service to serve a
# `<issuer>/.well-known/openid-configuration` endpoint. # `<issuer>/.well-known/openid-configuration` endpoint.
OIDC_ISSUER_DISCOVER: true OIDC_ISSUER_DISCOVER=true

View File

@@ -9,41 +9,57 @@ OUTPUT_FILE = f"__swarm/{stack_name}/{stack_name}-swarm.yml"
def fix_env_file(filepath): def fix_env_file(filepath):
"""Convert YAML-style env (KEY: value) into Docker env (KEY=value).""" """Convert YAML-style env (KEY: value) Docker env (KEY=value)."""
fixed_lines = [] fixed_lines = []
changed = False changed = False
with open(filepath, "r") as f: with open(filepath, "r") as f:
for line in f: for raw_line in f:
line = raw_line.rstrip("\n")
stripped = line.strip() stripped = line.strip()
# Skip empty/comment lines # Preserve comments and blank lines
if not stripped or stripped.startswith("#"): if not stripped or stripped.startswith("#"):
fixed_lines.append(line) fixed_lines.append(raw_line)
continue continue
# Match YAML-style: KEY: value # Detect YAML-style: KEY: value
m = re.match(r"^([A-Za-z0-9_]+):\s*(.*)$", stripped) # MUST convert
if m: if ":" in stripped and "=" not in stripped.split(":")[0]:
key, value = m.groups() key, value = stripped.split(":", 1)
fixed = f"{key}={value}\n" key = key.strip()
fixed_lines.append(fixed) value = value.strip()
changed = True
else:
# Validate Docker env format
if " " in stripped:
raise ValueError(f"Invalid env line (contains spaces): {stripped}")
if ":" in stripped:
raise ValueError(f"Invalid env line (contains colon): {stripped}")
fixed_lines.append(line)
# Write back only if changes were needed # Validate env key
if not re.match(r"^[A-Za-z0-9_]+$", key):
raise ValueError(f"Invalid variable name: {key}")
fixed_lines.append(f"{key}={value}\n")
changed = True
continue
# Detect valid Docker-style: KEY=value
if "=" in stripped:
key, value = stripped.split("=", 1)
# Validate key
if not re.match(r"^[A-Za-z0-9_]+$", key):
raise ValueError(f"Invalid environment variable name: {key}")
# Value may contain anything
fixed_lines.append(raw_line)
continue
# Anything else is invalid
raise ValueError(f"Invalid env line: {stripped}")
# Write file if modified
if changed: if changed:
with open(filepath, "w") as f: with open(filepath, "w") as f:
f.writelines(fixed_lines) f.writelines(fixed_lines)
print(f"[FIXED] Converted YAML env → Docker env in {filepath}") print(f"[FIXED] Converted YAML → Docker env format in {filepath}")
else: else:
print(f"[OK] .env file already valid: {filepath}") print(f"[OK] .env file valid: {filepath}")
def convert_ports(ports): def convert_ports(ports):
"""Convert short port syntax to Swarm long syntax.""" """Convert short port syntax to Swarm long syntax."""