fix(deploy): stabilize sass-embedded and runtime env files

This commit is contained in:
M_Kececi
2026-02-17 13:18:21 +03:00
parent 93446e6a69
commit 5ca00065e6

View File

@@ -11,6 +11,15 @@ LOG_FILE="/var/log/bssapp_deploy.log"
APP_DIR="/opt/bssapp" APP_DIR="/opt/bssapp"
LOCK_FILE="/tmp/bssapp_deploy.lock" LOCK_FILE="/tmp/bssapp_deploy.lock"
ensure_runtime_env_files() {
# Bazı unit dosyaları EnvironmentFile olarak bu path'leri bekliyor.
# Dosyalar yoksa systemd "Failed to load environment files" ile düşüyor.
[[ -f "$APP_DIR/.env" ]] || touch "$APP_DIR/.env"
[[ -f "$APP_DIR/mail.env" ]] || touch "$APP_DIR/mail.env"
[[ -f "$APP_DIR/svc/.env" ]] || touch "$APP_DIR/svc/.env"
[[ -f "$APP_DIR/svc/mail.env" ]] || touch "$APP_DIR/svc/mail.env"
}
build_api_binary() { build_api_binary() {
if ! command -v go >/dev/null 2>&1; then if ! command -v go >/dev/null 2>&1; then
echo "go command not found; cannot build backend binary." echo "go command not found; cannot build backend binary."
@@ -44,28 +53,18 @@ run_deploy() {
cd "$APP_DIR/ui" cd "$APP_DIR/ui"
npm ci --no-audit --no-fund --include=optional npm ci --no-audit --no-fund --include=optional
# npm scriptlerinde PATH onceligi nedeniyle node_modules/.bin/sass kullanilir. # Linux'ta sass --embedded hatasını engellemek için
# Bu dosya pure JS olursa --embedded hata verir; global Dart Sass binary'sine bagliyoruz. # deploy sırasında çalışan node_modules ağacına doğrudan yazıyoruz.
SASS_BIN="$(command -v sass || true)" npm i -D --no-audit --no-fund sass-embedded@1.93.2
if [[ -z "$SASS_BIN" ]]; then
echo "sass command not found in PATH."
return 1
fi
"$SASS_BIN" --embedded --version >/dev/null 2>&1 || {
echo "Global sass supports --embedded is not available."
return 1
}
ln -sf "$SASS_BIN" "$APP_DIR/ui/node_modules/.bin/sass"
"$APP_DIR/ui/node_modules/.bin/sass" --embedded --version >/dev/null 2>&1 || {
echo "node_modules/.bin/sass still does not support --embedded."
return 1
}
npm run build npm run build
echo "== BUILD API ==" echo "== BUILD API =="
build_api_binary build_api_binary
echo "== ENSURE ENV FILES =="
ensure_runtime_env_files
echo "== RESTART SERVICE ==" echo "== RESTART SERVICE =="
systemctl restart bssapp systemctl restart bssapp