mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 13:23:07 +01:00
Adds support for multiple hosts (#2059)
* Adds support for multiple hosts * Adds UI for drop down * Adds support for TLS and remove SSH * Changes dropdown to only show up with >1 hosts * Fixes js tests * Fixes go tests * Fixes download link * Updates readme * Removes unused imports * Fixes spaces
This commit is contained in:
40
main.go
40
main.go
@@ -48,6 +48,7 @@ type args struct {
|
||||
FilterStrings []string `arg:"env:DOZZLE_FILTER,--filter,separate" help:"filters docker containers using Docker syntax."`
|
||||
Filter map[string][]string `arg:"-"`
|
||||
Healthcheck *HealthcheckCmd `arg:"subcommand:healthcheck" help:"checks if the server is running."`
|
||||
RemoteHost []string `arg:"env:DOZZLE_REMOTE_HOST,--remote-host,separate" help:"list of hosts to connect remotely"`
|
||||
}
|
||||
|
||||
type HealthcheckCmd struct {
|
||||
@@ -91,6 +92,7 @@ func main() {
|
||||
}
|
||||
|
||||
log.Infof("Dozzle version %s", version)
|
||||
|
||||
dockerClient := docker.NewClientWithFilters(args.Filter)
|
||||
for i := 1; ; i++ {
|
||||
_, err := dockerClient.ListContainers()
|
||||
@@ -105,6 +107,15 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
clients := make(map[string]docker.Client)
|
||||
clients["localhost"] = dockerClient
|
||||
|
||||
for _, host := range args.RemoteHost {
|
||||
log.Infof("Creating a client for %s", host)
|
||||
client := docker.NewClientWithTlsAndFilter(args.Filter, host)
|
||||
clients[host] = client
|
||||
}
|
||||
|
||||
if args.Username == "" && args.UsernameFile != nil {
|
||||
args.Username = args.UsernameFile.Value
|
||||
}
|
||||
@@ -120,12 +131,12 @@ func main() {
|
||||
}
|
||||
|
||||
config := web.Config{
|
||||
Addr: args.Addr,
|
||||
Base: args.Base,
|
||||
Version: version,
|
||||
Username: args.Username,
|
||||
Password: args.Password,
|
||||
Hostname: args.Hostname,
|
||||
Addr: args.Addr,
|
||||
Base: args.Base,
|
||||
Version: version,
|
||||
Username: args.Username,
|
||||
Password: args.Password,
|
||||
Hostname: args.Hostname,
|
||||
NoAnalytics: args.NoAnalytics,
|
||||
}
|
||||
|
||||
@@ -139,7 +150,7 @@ func main() {
|
||||
assets = os.DirFS("./dist")
|
||||
}
|
||||
|
||||
srv := web.CreateServer(dockerClient, assets, config)
|
||||
srv := web.CreateServer(clients, assets, config)
|
||||
go doStartEvent(args)
|
||||
go func() {
|
||||
log.Infof("Accepting connections on %s", srv.Addr)
|
||||
@@ -171,13 +182,14 @@ func doStartEvent(arg args) {
|
||||
}
|
||||
|
||||
event := analytics.StartEvent{
|
||||
ClientId: host,
|
||||
Version: version,
|
||||
FilterLength: len(arg.Filter),
|
||||
CustomAddress: arg.Addr != ":8080",
|
||||
CustomBase: arg.Base != "/",
|
||||
Protected: arg.Username != "",
|
||||
HasHostname: arg.Hostname != "",
|
||||
ClientId: host,
|
||||
Version: version,
|
||||
FilterLength: len(arg.Filter),
|
||||
CustomAddress: arg.Addr != ":8080",
|
||||
CustomBase: arg.Base != "/",
|
||||
RemoteHostLength: len(arg.RemoteHost),
|
||||
Protected: arg.Username != "",
|
||||
HasHostname: arg.Hostname != "",
|
||||
}
|
||||
|
||||
if err := analytics.SendStartEvent(event); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user