mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 13:23:07 +01:00
fix: Use /tmp instead of ./ to ensure that user permissions can be mounted correctly. (#3797)
This commit is contained in:
@@ -61,6 +61,7 @@ RUN mkdir /data
|
|||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
COPY --from=builder /data /data
|
COPY --from=builder /data /data
|
||||||
|
COPY --from=builder /tmp /tmp
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
COPY --from=builder /dozzle/dozzle /dozzle
|
COPY --from=builder /dozzle/dozzle /dozzle
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type AgentCmd struct {
|
type AgentCmd struct {
|
||||||
Addr string `arg:"--agent-addr,env:DOZZLE_AGENT_ADDR" default:":7007" help:"sets the host:port to bind for the agent"`
|
Addr string `arg:"--agent-addr,env:DOZZLE_AGENT_ADDR" default:":7007" help:"sets the host:port to bind for the agent"`
|
||||||
}
|
}
|
||||||
@@ -37,11 +36,12 @@ func (a *AgentCmd) Run(args Args, embeddedCerts embed.FS) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to listen: %w", err)
|
return fmt.Errorf("failed to listen: %w", err)
|
||||||
}
|
}
|
||||||
tempFile, err := os.CreateTemp("./", "agent-*.addr")
|
tempFile, err := os.CreateTemp("", "agent-*.addr")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create temp file: %w", err)
|
return fmt.Errorf("failed to create temp file: %w", err)
|
||||||
}
|
}
|
||||||
io.WriteString(tempFile, listener.Addr().String())
|
io.WriteString(tempFile, listener.Addr().String())
|
||||||
|
log.Debug().Str("file", tempFile.Name()).Msg("Created temp file")
|
||||||
go StartEvent(args, "", client, "agent")
|
go StartEvent(args, "", client, "agent")
|
||||||
server, err := agent.NewServer(client, certs, args.Version(), args.Filter)
|
server, err := agent.NewServer(client, certs, args.Version(), args.Filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -8,43 +8,29 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/amir20/dozzle/internal/healthcheck"
|
"github.com/amir20/dozzle/internal/healthcheck"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HealthcheckCmd struct {
|
type HealthcheckCmd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HealthcheckCmd) Run(args Args, embeddedCerts embed.FS) error {
|
func (h *HealthcheckCmd) Run(args Args, embeddedCerts embed.FS) error {
|
||||||
files, err := os.ReadDir(".")
|
if matches, err := filepath.Glob("/tmp/agent-*.addr"); err == nil && len(matches) == 1 {
|
||||||
if err != nil {
|
data, err := os.ReadFile(matches[0])
|
||||||
return fmt.Errorf("failed to read directory: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
agentAddress := ""
|
|
||||||
for _, file := range files {
|
|
||||||
if match, _ := filepath.Match("agent-*.addr", file.Name()); match {
|
|
||||||
data, err := os.ReadFile(file.Name())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read file: %w", err)
|
return fmt.Errorf("failed to read file: %w", err)
|
||||||
}
|
}
|
||||||
agentAddress = string(data)
|
agentAddress := string(data)
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if agentAddress == "" {
|
|
||||||
if err := healthcheck.HttpRequest(args.Addr, args.Base); err != nil {
|
|
||||||
return fmt.Errorf("failed to make request: %w", err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
certs, err := ReadCertificates(embeddedCerts)
|
certs, err := ReadCertificates(embeddedCerts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read certificates: %w", err)
|
return fmt.Errorf("failed to read certificates: %w", err)
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), args.Timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), args.Timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := healthcheck.RPCRequest(ctx, agentAddress, certs); err != nil {
|
log.Info().Str("address", agentAddress).Msg("Making RPC request to agent")
|
||||||
return fmt.Errorf("failed to make request: %w", err)
|
return healthcheck.RPCRequest(ctx, agentAddress, certs)
|
||||||
|
} else {
|
||||||
|
log.Info().Str("address", args.Addr).Str("base", args.Base).Msg("Making HTTP request to server")
|
||||||
|
return healthcheck.HttpRequest(args.Addr, args.Base)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user