mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- Add main Dockerfile for production builds - Add Dockerfile.runtime for secure code execution - Add Dockerfile.runtime.fixed with improved configuration - Include .dockerignore for build optimization - Add integration documentation and publishing guides - Update API and CLI components for better runtime support - Enhance sandbox and container management features
49 lines
846 B
Go
49 lines
846 B
Go
// Copyright 2025 Hanzo Industries Inc.
|
|
// SPDX-License-Identifier: AGPL-3.0
|
|
|
|
package daemon
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func WriteStaticBinary(name string) (string, error) {
|
|
daemonBinary, err := static.ReadFile(fmt.Sprintf("static/%s", name))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
pwd, err := os.Getwd()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
tmpBinariesDir := filepath.Join(pwd, ".tmp", "binaries")
|
|
err = os.MkdirAll(tmpBinariesDir, 0755)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
daemonPath := filepath.Join(tmpBinariesDir, name)
|
|
_, err = os.Stat(daemonPath)
|
|
if err != nil && !os.IsNotExist(err) {
|
|
return "", err
|
|
}
|
|
|
|
if err == nil {
|
|
err = os.Remove(daemonPath)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
}
|
|
|
|
err = os.WriteFile(daemonPath, daemonBinary, 0755)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return daemonPath, nil
|
|
}
|