updated files for a prod env

This commit is contained in:
Hendrik Behme committed 2026-08-17 01:20:47 +02:00
1 parent 551b06e68a
commit 4182510795
8 files changed
+152 -17

No files matched your search

+23
View File
@@ -2,6 +2,8 @@ package main
import (
"log"
"net/http"
"os"
"whimsoc/vindn-backend/config"
"whimsoc/vindn-backend/models"
"whimsoc/vindn-backend/repositories"
@@ -9,9 +11,23 @@ import (
"whimsoc/vindn-backend/tasks"
"github.com/gofiber/fiber/v2"
// Embeds the IANA timezone database into the binary so TZ=Europe/Berlin
// (see docker-compose.yaml) resolves correctly even on a minimal runtime
// image that might not ship /usr/share/zoneinfo — the twice-daily cron
// schedule in tasks/Cronjob.go depends on this being right.
_ "time/tzdata"
)
func main() {
// The prod runtime image is distroless (no shell, no wget/curl), so
// Docker's HEALTHCHECK runs this binary in a second mode instead of a
// separate tool — see backend/Dockerfile.prod.
if len(os.Args) > 1 && os.Args[1] == "healthcheck" {
runHealthcheck()
return
}
// Lade .env
config.LoadEnv()
@@ -44,3 +60,10 @@ func main() {
log.Fatal(app.Listen(":" + config.GetEnv("PORT", "8080")))
}
func runHealthcheck() {
resp, err := http.Get("http://localhost:" + config.GetEnv("PORT", "8080") + "/health")
if err != nil || resp.StatusCode != http.StatusOK {
os.Exit(1)
}
}