Compare commits
3 commits
8421c6999a
...
0ae784f234
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ae784f234 | ||
|
|
1d5aa2aabd | ||
|
|
413238d6f4 |
13 changed files with 69 additions and 7 deletions
47
bank/build.sh
Normal file
47
bank/build.sh
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/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
Executable file
BIN
bank/dist/securebank-embedded
vendored
Executable file
Binary file not shown.
BIN
bank/dist/securebank-windows.exe
vendored
Executable file
BIN
bank/dist/securebank-windows.exe
vendored
Executable file
Binary file not shown.
|
|
@ -1,14 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
||||
//go:embed templates/*
|
||||
var templatesFS embed.FS
|
||||
|
||||
//go:embed static/*
|
||||
var staticFS embed.FS
|
||||
|
||||
// User struktura za uporabniške podatke
|
||||
type User struct {
|
||||
ID int
|
||||
|
|
@ -52,15 +60,19 @@ func main() {
|
|||
var port = flag.String("port", "8080", "Port na katerem se bo zagnal server")
|
||||
flag.Parse()
|
||||
|
||||
// Naložimo HTML predloge
|
||||
// Naložimo HTML predloge iz embedded FS
|
||||
var err error
|
||||
templates, err = template.ParseGlob("templates/*.html")
|
||||
templates, err = template.ParseFS(templatesFS, "templates/*.html")
|
||||
if err != nil {
|
||||
log.Fatal("Napaka pri nalaganju predlog:", err)
|
||||
log.Fatal("Napaka pri nalaganju embedded predlog:", err)
|
||||
}
|
||||
|
||||
// Statične datoteke (CSS)
|
||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
|
||||
// Statične datoteke iz embedded FS
|
||||
staticSubFS, err := fs.Sub(staticFS, "static")
|
||||
if err != nil {
|
||||
log.Fatal("Napaka pri ustvarjanju static subFS:", err)
|
||||
}
|
||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSubFS))))
|
||||
|
||||
// Routes
|
||||
http.HandleFunc("/", homeHandler)
|
||||
|
|
@ -70,8 +82,11 @@ func main() {
|
|||
http.HandleFunc("/logout", logoutHandler)
|
||||
|
||||
// Zagon strežnika
|
||||
fmt.Printf("SecureBank aplikacija se zaganja na portu %s\n", *port)
|
||||
fmt.Printf("Dostop: http://localhost:%s\n", *port)
|
||||
fmt.Printf("🏦 SecureBank aplikacija (embedded build)\n")
|
||||
fmt.Printf("Port: %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
|
||||
log.Fatal(http.ListenAndServe(serverAddr, nil))
|
||||
Loading…
Add table
Add a link
Reference in a new issue