From 9a66d2c87a56a22340b2d587d3334b863d66b216 Mon Sep 17 00:00:00 2001 From: Michael Reber Date: Wed, 26 Feb 2025 20:40:31 +0100 Subject: [PATCH] Fix Dockerfile to include language files --- Dockerfile | 3 ++- cmd/server/main.go | 4 +++- pkg/web/routes.go | 3 --- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ddda406..43c1646 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # ========================================= # STAGE 1: Build Fail2Ban UI Binary # ========================================= -FROM golang:1.22.9 AS builder +FROM golang:1.23 AS builder WORKDIR /app @@ -41,6 +41,7 @@ WORKDIR /config COPY --from=builder /app/fail2ban-ui /app/fail2ban-ui RUN chown fail2ban:0 /app/fail2ban-ui && chmod +x /app/fail2ban-ui COPY --from=builder /app/pkg/web/templates /app/templates +COPY --from=builder /app/internal/locales /app/locales # Set environment variables ENV CONTAINER=true diff --git a/cmd/server/main.go b/cmd/server/main.go index 75af774..89a2e78 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -32,12 +32,14 @@ func main() { if container { // In container, templates are assumed to be in /app/templates router.LoadHTMLGlob("/app/templates/*") + router.Static("/locales", "/app/locales") } else { // When running locally, load templates from pkg/web/templates router.LoadHTMLGlob("pkg/web/templates/*") + router.Static("/locales", "./internal/locales") } - // Register all application routes, including the static file serving route for locales. + // Register all application routes, including the static files and templates. web.RegisterRoutes(router) printWelcomeBanner(serverPort) diff --git a/pkg/web/routes.go b/pkg/web/routes.go index 074e42b..04d65dc 100644 --- a/pkg/web/routes.go +++ b/pkg/web/routes.go @@ -22,9 +22,6 @@ import ( // RegisterRoutes sets up the routes for the Fail2ban UI. func RegisterRoutes(r *gin.Engine) { - // Serve static files for locales from the "internal/locales" directory. - // (This makes the translation files available under the /locales/ URL.) - r.Static("/locales", "./internal/locales") // Render the dashboard r.GET("/", IndexHandler)