Refactor Docker setup to integrate Web UI and streamline configuration
- Updated Dockerfile to build and embed the SvelteKit Web UI directly into the gateway image, eliminating the need for a separate web service. - Modified .dockerignore to exclude unnecessary directories related to the web service. - Adjusted config.compose.yaml to remove CORS settings for the web service, as the UI now shares the same origin as the API. - Enhanced README.md to reflect the new single-port architecture for accessing both the Web UI and API. - Removed the standalone web Dockerfile and updated related documentation for local development and build processes.
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/telemt/telemt-api/internal/config"
|
||||
"github.com/telemt/telemt-api/internal/geoip"
|
||||
"github.com/telemt/telemt-api/internal/proxy"
|
||||
"github.com/telemt/telemt-api/internal/webui"
|
||||
)
|
||||
|
||||
// Gateway serves health, metrics, and proxied API routes.
|
||||
@@ -29,6 +30,7 @@ type Gateway struct {
|
||||
transport *http.Transport
|
||||
promHandler http.Handler
|
||||
corsAllowed []string
|
||||
webUI http.Handler
|
||||
}
|
||||
|
||||
// NewGateway builds handlers and reverse proxies from parsed config.
|
||||
@@ -75,6 +77,7 @@ func NewGateway(p *config.Parsed, log *slog.Logger, geo *geoip.Service) (*Gatewa
|
||||
}
|
||||
g.corsAllowed = append([]string(nil), p.Config.CorsAllowedOrigins...)
|
||||
g.agg = aggregate.NewHandler(p, &http.Client{Transport: t}, geo, aggCacheTTL)
|
||||
g.webUI = webui.Handler()
|
||||
return g, nil
|
||||
}
|
||||
|
||||
@@ -231,7 +234,7 @@ func (g *Gateway) serve(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if !strings.HasPrefix(r.URL.Path, prefix) {
|
||||
http.NotFound(w, r)
|
||||
g.webUI.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
trim := strings.TrimPrefix(r.URL.Path, prefix)
|
||||
|
||||
Reference in New Issue
Block a user