1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00

fix: fixes an edge case where a container might get stuck in created state (#3338)

This commit is contained in:
Amir Raminfar
2024-10-21 13:14:50 -07:00
committed by GitHub
parent 4026e927f5
commit f3ab541ad1
4 changed files with 48 additions and 26 deletions

View File

@@ -67,6 +67,7 @@ func CreateServer(multiHostService *MultiHostService, content fs.FS, config Conf
var fileServer http.Handler
func createRouter(h *handler) *chi.Mux {
fileServer = http.FileServer(http.FS(h.content))
base := h.config.Base
r := chi.NewRouter()
@@ -82,41 +83,46 @@ func createRouter(h *handler) *chi.Mux {
if h.config.Authorization.Provider != NONE {
r.Use(h.config.Authorization.Authorizer.AuthMiddleware)
}
r.Group(func(r chi.Router) {
r.Route("/api", func(r chi.Router) {
// Authenticated routes
r.Group(func(r chi.Router) {
if h.config.Authorization.Provider != NONE {
r.Use(auth.RequireAuthentication)
}
r.Get("/api/hosts/{host}/containers/{id}/logs/stream", h.streamContainerLogs)
r.Get("/api/hosts/{host}/containers/{id}/logs/download", h.downloadLogs)
r.Get("/api/hosts/{host}/containers/{id}/logs", h.fetchLogsBetweenDates)
r.Get("/api/hosts/{host}/logs/mergedStream/{ids}", h.streamLogsMerged)
r.Get("/api/stacks/{stack}/logs/stream", h.streamStackLogs)
r.Get("/api/services/{service}/logs/stream", h.streamServiceLogs)
r.Get("/api/groups/{group}/logs/stream", h.streamGroupedLogs)
r.Get("/api/events/stream", h.streamEvents)
r.Get("/hosts/{host}/containers/{id}/logs/stream", h.streamContainerLogs)
r.Get("/hosts/{host}/containers/{id}/logs/download", h.downloadLogs)
r.Get("/hosts/{host}/containers/{id}/logs", h.fetchLogsBetweenDates)
r.Get("/hosts/{host}/logs/mergedStream/{ids}", h.streamLogsMerged)
r.Get("/stacks/{stack}/logs/stream", h.streamStackLogs)
r.Get("/services/{service}/logs/stream", h.streamServiceLogs)
r.Get("/groups/{group}/logs/stream", h.streamGroupedLogs)
r.Get("/events/stream", h.streamEvents)
if h.config.EnableActions {
r.Post("/api/hosts/{host}/containers/{id}/actions/{action}", h.containerActions)
r.Post("/hosts/{host}/containers/{id}/actions/{action}", h.containerActions)
}
r.Get("/api/releases", h.releases)
r.Get("/api/profile/avatar", h.avatar)
r.Patch("/api/profile", h.updateProfile)
r.Get("/releases", h.releases)
r.Get("/profile/avatar", h.avatar)
r.Patch("/profile", h.updateProfile)
r.Get("/version", h.version)
if log.Debug().Enabled() {
r.Get("/debug/store", h.debugStore)
}
})
defaultHandler := http.StripPrefix(strings.Replace(base+"/", "//", "/", 1), http.HandlerFunc(h.index))
r.Get("/*", func(w http.ResponseWriter, req *http.Request) {
defaultHandler.ServeHTTP(w, req)
})
// Public API routes
if h.config.Authorization.Provider == SIMPLE {
r.Post("/token", h.createToken)
r.Delete("/token", h.deleteToken)
}
})
if h.config.Authorization.Provider == SIMPLE {
r.Post("/api/token", h.createToken)
r.Delete("/api/token", h.deleteToken)
}
r.Get("/healthcheck", h.healthcheck)
defaultHandler := http.StripPrefix(strings.Replace(base+"/", "//", "/", 1), http.HandlerFunc(h.index))
r.Get("/*", func(w http.ResponseWriter, req *http.Request) {
defaultHandler.ServeHTTP(w, req)
})
})
if base != "/" {
@@ -125,8 +131,6 @@ func createRouter(h *handler) *chi.Mux {
})
}
fileServer = http.FileServer(http.FS(h.content))
// r.Mount("/debug", middleware.Profiler())
return r