fix: handle missing config file gracefully in Docker
All checks were successful
Build and Push Docker Image / build (push) Successful in 14s

This commit is contained in:
2026-01-01 12:51:25 -05:00
parent 107db82c52
commit ca03d22b97

View File

@@ -74,19 +74,34 @@ def _ensure_config(config_path: str) -> bool:
# Check if path is a directory (Docker creates this when mounting missing file) # Check if path is a directory (Docker creates this when mounting missing file)
if os.path.isdir(path): if os.path.isdir(path):
os.rmdir(path) print(f"ERROR: Config path is a directory: {path}")
print()
print("This usually means the config file doesn't exist on the host.")
print("Please create the config file before starting the container:")
print()
print(f" mkdir -p $(dirname {config_path})")
print(f" cat > {config_path} << 'EOF'")
print(CONFIG_TEMPLATE)
print("EOF")
print()
return False
if os.path.exists(path): if os.path.exists(path):
return True return True
# Create template config # Create template config
with open(path, "w") as f: try:
f.write(CONFIG_TEMPLATE) with open(path, "w") as f:
f.write(CONFIG_TEMPLATE)
print(f"Created template configuration at: {path}") print(f"Created template configuration at: {path}")
print() print()
print("Please edit this file to configure your Grist documents and agent tokens,") print("Please edit this file to configure your Grist documents and agent tokens,")
print("then restart the server.") print("then restart the server.")
except PermissionError:
print(f"ERROR: Cannot create config file at: {path}")
print()
print("Please create the config file manually before starting the container.")
print()
return False return False