fix: Add dynamic base-path support for code-server subpath routing
code-server needs to know its base path for correct asset loading.
The Traefik StripPrefix middleware removes the path before requests
reach the container, so assets were loading from wrong URLs.
Solution:
- Entrypoint script reads BASE_PATH env var and passes to code-server
- container_manager.py sets BASE_PATH=/{slug_with_suffix} for vcoder
- code-server now loads assets from correct relative paths
This fixes 404 errors on workbench.css, nls.messages.js, etc.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3e4928c378
commit
0d1f4f1db9
|
|
@ -248,17 +248,24 @@ class ContainerManager:
|
||||||
for host, config in volumes.items():
|
for host, config in volumes.items():
|
||||||
print(f"[SPAWNER] {host} -> {config['bind']}")
|
print(f"[SPAWNER] {host} -> {config['bind']}")
|
||||||
|
|
||||||
|
# Environment-Variablen für Container
|
||||||
|
env_vars = {
|
||||||
|
'USER_ID': str(user_id),
|
||||||
|
'USER_SLUG': slug,
|
||||||
|
'CONTAINER_TYPE': container_type,
|
||||||
|
'JWT_SECRET': Config.SECRET_KEY # Für Token-Validierung im Container
|
||||||
|
}
|
||||||
|
|
||||||
|
# vcoder braucht BASE_PATH für code-server Subpath-Routing
|
||||||
|
if container_type == 'vcoder':
|
||||||
|
env_vars['BASE_PATH'] = f'/{slug_with_suffix}'
|
||||||
|
|
||||||
container = self._get_client().containers.run(
|
container = self._get_client().containers.run(
|
||||||
image=image,
|
image=image,
|
||||||
name=container_name,
|
name=container_name,
|
||||||
detach=True,
|
detach=True,
|
||||||
labels=labels,
|
labels=labels,
|
||||||
environment={
|
environment=env_vars,
|
||||||
'USER_ID': str(user_id),
|
|
||||||
'USER_SLUG': slug,
|
|
||||||
'CONTAINER_TYPE': container_type,
|
|
||||||
'JWT_SECRET': Config.SECRET_KEY # Für Token-Validierung im Container
|
|
||||||
},
|
|
||||||
restart_policy={'Name': 'unless-stopped'},
|
restart_policy={'Name': 'unless-stopped'},
|
||||||
mem_limit=Config.DEFAULT_MEMORY_LIMIT,
|
mem_limit=Config.DEFAULT_MEMORY_LIMIT,
|
||||||
cpu_quota=Config.DEFAULT_CPU_QUOTA,
|
cpu_quota=Config.DEFAULT_CPU_QUOTA,
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,13 @@ RUN apt-get update && apt-get install -y socat && rm -rf /var/lib/apt/lists/*
|
||||||
# Entrypoint-Script - startet socat Tunnel + code-server
|
# Entrypoint-Script - startet socat Tunnel + code-server
|
||||||
RUN printf '#!/bin/bash\n\
|
RUN printf '#!/bin/bash\n\
|
||||||
socat TCP-LISTEN:8008,reuseaddr,fork TCP:localhost:9009 &\n\
|
socat TCP-LISTEN:8008,reuseaddr,fork TCP:localhost:9009 &\n\
|
||||||
|
# Wenn BASE_PATH nicht gesetzt, nutze "/"\n\
|
||||||
|
BASE_PATH="${BASE_PATH:=/}"\n\
|
||||||
|
# Ersetze in CMD das --bind-addr mit vollständigen Flags\n\
|
||||||
|
if [ "$1" = "code-server" ]; then\n\
|
||||||
|
shift\n\
|
||||||
|
exec code-server "--bind-addr" "0.0.0.0:8080" "--base-path" "$BASE_PATH" "--auth" "none" "$@"\n\
|
||||||
|
fi\n\
|
||||||
exec "$@"\n' > /entrypoint.sh && chmod +x /entrypoint.sh
|
exec "$@"\n' > /entrypoint.sh && chmod +x /entrypoint.sh
|
||||||
|
|
||||||
USER coder
|
USER coder
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user