mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 10:18:39 +00:00
fixes https://github.com/aenix-io/cozystack/issues/602 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new custom assets server for serving static files - Replaced `darkhttpd` with a custom Go-based file server - **Improvements** - Updated base images to Alpine Linux 3.21 - Simplified container dependencies - Enhanced server configuration with command-line flags - **Infrastructure** - Rebuilt Kubernetes deployment configuration for assets service - Updated server startup parameters and container settings <!-- end of auto-generated comment: release notes by coderabbit.ai -->
30 lines
615 B
Go
30 lines
615 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"net/http"
|
|
"path/filepath"
|
|
)
|
|
|
|
func main() {
|
|
addr := flag.String("address", ":8123", "Address to listen on")
|
|
dir := flag.String("dir", "/cozystack/assets", "Directory to serve files from")
|
|
flag.Parse()
|
|
|
|
absDir, err := filepath.Abs(*dir)
|
|
if err != nil {
|
|
log.Fatalf("Error getting absolute path for %s: %v", *dir, err)
|
|
}
|
|
|
|
fs := http.FileServer(http.Dir(absDir))
|
|
http.Handle("/", fs)
|
|
|
|
log.Printf("Server starting on %s, serving directory %s", *addr, absDir)
|
|
|
|
err = http.ListenAndServe(*addr, nil)
|
|
if err != nil {
|
|
log.Fatalf("Server failed to start: %v", err)
|
|
}
|
|
}
|