Compare commits
No commits in common. "0ae784f2343d8c278a35b91512d6aa671ddbe31d" and "8421c6999a37293c0de51a4420657f2763f8165c" have entirely different histories.
0ae784f234
...
8421c6999a
13 changed files with 7 additions and 69 deletions
|
|
@ -1,47 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# SecureBank - Build Script
|
|
||||||
# Ustvari standalone izvršilne datoteke z vključenimi resources
|
|
||||||
|
|
||||||
echo "🏗️ SecureBank - Build processo"
|
|
||||||
echo "================================"
|
|
||||||
|
|
||||||
# Preveri če obstajajo potrebni direktoriji
|
|
||||||
if [ ! -d "templates" ] || [ ! -d "static" ]; then
|
|
||||||
echo "❌ Napaka: Manjkajo templates/ vagy static/ direktoriji!"
|
|
||||||
echo " Poženite script iz /bank direktorija"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ustvari build direktorij
|
|
||||||
mkdir -p dist
|
|
||||||
|
|
||||||
echo "📦 Building za Linux (amd64)..."
|
|
||||||
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/securebank-linux ./
|
|
||||||
echo "✅ Linux binary: dist/securebank-linux"
|
|
||||||
|
|
||||||
echo "📦 Building za Windows (amd64)..."
|
|
||||||
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/securebank-windows.exe ./
|
|
||||||
echo "✅ Windows binary: dist/securebank-windows.exe"
|
|
||||||
|
|
||||||
echo "📦 Building za macOS (amd64)..."
|
|
||||||
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/securebank-macos ./
|
|
||||||
echo "✅ macOS binary: dist/securebank-macos"
|
|
||||||
|
|
||||||
echo "📦 Building za macOS (ARM64 - M1/M2)..."
|
|
||||||
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/securebank-macos-arm64 ./
|
|
||||||
echo "✅ macOS ARM binary: dist/securebank-macos-arm64"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "🎉 Build process končan!"
|
|
||||||
echo ""
|
|
||||||
echo "📁 Izvršilne datoteke v dist/ direktoriju:"
|
|
||||||
ls -la dist/
|
|
||||||
echo ""
|
|
||||||
echo "🚀 Testiranje:"
|
|
||||||
echo " ./dist/securebank-linux -port 8080"
|
|
||||||
echo ""
|
|
||||||
echo "📋 Opozorilo:"
|
|
||||||
echo " - Vsi HTML, CSS in JS fajli so vključeni v binary"
|
|
||||||
echo " - Binary lahko kopirate kjerkoli - ne potrebuje dodatnih datotek"
|
|
||||||
echo " - Za deployment samo kopirajte binary datoteko"
|
|
||||||
BIN
bank/dist/securebank-embedded
vendored
BIN
bank/dist/securebank-embedded
vendored
Binary file not shown.
BIN
bank/dist/securebank-windows.exe
vendored
BIN
bank/dist/securebank-windows.exe
vendored
Binary file not shown.
|
|
@ -1,22 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed templates/*
|
|
||||||
var templatesFS embed.FS
|
|
||||||
|
|
||||||
//go:embed static/*
|
|
||||||
var staticFS embed.FS
|
|
||||||
|
|
||||||
// User struktura za uporabniške podatke
|
// User struktura za uporabniške podatke
|
||||||
type User struct {
|
type User struct {
|
||||||
ID int
|
ID int
|
||||||
|
|
@ -60,19 +52,15 @@ func main() {
|
||||||
var port = flag.String("port", "8080", "Port na katerem se bo zagnal server")
|
var port = flag.String("port", "8080", "Port na katerem se bo zagnal server")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// Naložimo HTML predloge iz embedded FS
|
// Naložimo HTML predloge
|
||||||
var err error
|
var err error
|
||||||
templates, err = template.ParseFS(templatesFS, "templates/*.html")
|
templates, err = template.ParseGlob("templates/*.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Napaka pri nalaganju embedded predlog:", err)
|
log.Fatal("Napaka pri nalaganju predlog:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Statične datoteke iz embedded FS
|
// Statične datoteke (CSS)
|
||||||
staticSubFS, err := fs.Sub(staticFS, "static")
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Napaka pri ustvarjanju static subFS:", err)
|
|
||||||
}
|
|
||||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSubFS))))
|
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
http.HandleFunc("/", homeHandler)
|
http.HandleFunc("/", homeHandler)
|
||||||
|
|
@ -82,11 +70,8 @@ func main() {
|
||||||
http.HandleFunc("/logout", logoutHandler)
|
http.HandleFunc("/logout", logoutHandler)
|
||||||
|
|
||||||
// Zagon strežnika
|
// Zagon strežnika
|
||||||
fmt.Printf("🏦 SecureBank aplikacija (embedded build)\n")
|
fmt.Printf("SecureBank aplikacija se zaganja na portu %s\n", *port)
|
||||||
fmt.Printf("Port: %s\n", *port)
|
fmt.Printf("Dostop: http://localhost:%s\n", *port)
|
||||||
fmt.Printf("HTTP: http://localhost:%s\n", *port)
|
|
||||||
fmt.Printf("📦 Vsi fajli so vključeni v binary!\n")
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
serverAddr := ":" + *port
|
serverAddr := ":" + *port
|
||||||
log.Fatal(http.ListenAndServe(serverAddr, nil))
|
log.Fatal(http.ListenAndServe(serverAddr, nil))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue