added docker setup
This commit is contained in:
15
main.go
15
main.go
@@ -8,6 +8,7 @@ import (
|
||||
"mealprep/database"
|
||||
"mealprep/handlers"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -15,8 +16,14 @@ func main() {
|
||||
// Print startup banner
|
||||
printBanner()
|
||||
|
||||
// Get database path from environment variable or use default
|
||||
dbPath := os.Getenv("DB_PATH")
|
||||
if dbPath == "" {
|
||||
dbPath = "mealprep.db"
|
||||
}
|
||||
|
||||
// Initialize database
|
||||
if err := database.InitDB("mealprep.db"); err != nil {
|
||||
if err := database.InitDB(dbPath); err != nil {
|
||||
log.Fatalf("Failed to initialize database: %v", err)
|
||||
}
|
||||
defer database.DB.Close()
|
||||
@@ -48,6 +55,12 @@ func main() {
|
||||
})
|
||||
http.HandleFunc("/logout", handlers.LogoutHandler)
|
||||
|
||||
// Health check endpoint (public, for Docker)
|
||||
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("OK"))
|
||||
})
|
||||
|
||||
// Protected routes
|
||||
http.HandleFunc("/", auth.RequireAuth(indexHandler))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user