Add Coolify deployment configuration

This commit is contained in:
2025-07-07 21:42:30 +02:00
parent 587870e5f6
commit 0232cd0c20
8 changed files with 731 additions and 48 deletions

29
main.go
View File

@ -4,6 +4,7 @@ import (
"html/template"
"log"
"net/http"
"os"
)
// Configuration holds all website configuration
@ -30,15 +31,23 @@ type Server struct {
templates *template.Template
}
// getEnv returns environment variable or default value
func getEnv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}
// NewServer creates a new server instance
func NewServer() *Server {
// Configuration - replace these with your actual values
// Configuration - can be overridden with environment variables
config := Config{
CompanyName: "Hogeland Linux",
KVK: "12345678", // Replace with actual KVK number
Email: "info@hogelandlinux.nl",
Phone: "+31 6 12345678",
Port: ":8080",
CompanyName: getEnv("COMPANY_NAME", "Hogeland Linux"),
KVK: getEnv("KVK", "12345678"), // Replace with actual KVK number
Email: getEnv("EMAIL", "info@hogelandlinux.nl"),
Phone: getEnv("PHONE", "+31 6 12345678"),
Port: ":" + getEnv("PORT", "8080"),
}
// Parse templates with error handling
@ -84,6 +93,13 @@ func (s *Server) contactHandler(w http.ResponseWriter, r *http.Request) {
s.renderTemplate(w, "contact.html", data)
}
// healthHandler provides a simple health check endpoint
func (s *Server) healthHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"status":"healthy","service":"linuxservice"}`))
}
// setupRoutes configures all HTTP routes
func (s *Server) setupRoutes() {
// Static files
@ -93,6 +109,7 @@ func (s *Server) setupRoutes() {
// Page routes
http.HandleFunc("/", s.homeHandler)
http.HandleFunc("/contact", s.contactHandler)
http.HandleFunc("/health", s.healthHandler)
}
func main() {