feat(builder): py_compile + node --check при сборке ловят синтаксические ошибки (v0.1.63)

This commit is contained in:
Naeel
2026-03-23 11:23:01 +03:00
parent 8051870208
commit 3404af578b
+6
View File
@@ -132,11 +132,17 @@ func generateDockerfile(runtime string, hasRequirements bool, hasPackageJSON boo
if hasRequirements { if hasRequirements {
content += "RUN pip install --no-cache-dir -r /app/function/requirements.txt\n" content += "RUN pip install --no-cache-dir -r /app/function/requirements.txt\n"
} }
// Проверяем синтаксис всех .py файлов на этапе сборки образа.
// Если в коде синтаксическая ошибка — kaniko завершится с ошибкой и фаза = Failed.
// Без этого шага образ собирается успешно, а под падает в CrashLoopBackOff при запуске.
content += "RUN python -m py_compile $(find /app/function -name '*.py')\n"
case "nodejs20": case "nodejs20":
if hasPackageJSON { if hasPackageJSON {
// cd нужен т.к. npm install читает package.json из текущей директории // cd нужен т.к. npm install читает package.json из текущей директории
content += "RUN cd /app/function && npm install --omit=dev\n" content += "RUN cd /app/function && npm install --omit=dev\n"
} }
// Проверяем синтаксис всех .js файлов через node --check.
content += "RUN find /app/function -name '*.js' | xargs -r node --check\n"
} }
return []byte(content), nil return []byte(content), nil
} }