diff --git a/Dockerfile b/Dockerfile index b50dc45..86b496d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,17 @@ FROM golang:alpine AS builder + WORKDIR /app RUN apk --no-cache add make; -COPY go.mod . -COPY go.sum . - -RUN go mod download; COPY . . -ENV GOCACHE=/cache/go-build -RUN --mount=type=cache,target="/cache/go-build" mkdir -p /cache/go-build; make hivemind; +RUN make hivemind; FROM alpine EXPOSE 56714/tcp + WORKDIR /app VOLUME /conf @@ -24,4 +21,5 @@ ENV HIVEMIND_CONFIG_FILE=/conf/config.toml ENV HIVEMIND_REGISTRY_FILE=/data/registry.json COPY --from=builder /app/build/hivemind . + CMD ["./hivemind"] diff --git a/internal/roles/dns/dns.go b/internal/roles/dns/dns.go index 66efb45..ffe3a66 100644 --- a/internal/roles/dns/dns.go +++ b/internal/roles/dns/dns.go @@ -48,10 +48,10 @@ func parseState(state types.HostState) (string, []byte) { var builder strings.Builder for _, d := range state.Domains { - builder.WriteString(fmt.Sprintf("%s %s\n", state.Endpoint, d)) + builder.WriteString(fmt.Sprintf("%s %s\n", state.Name, d)) } - return hostsDir + state.Name, []byte(builder.String()) + return hostsDir + state.Endpoint, []byte(builder.String()) } func (r *Role) OnStartup(ctx context.Context) error { diff --git a/internal/roles/host/host.go b/internal/roles/host/host.go index 6bdea06..e67c2bf 100644 --- a/internal/roles/host/host.go +++ b/internal/roles/host/host.go @@ -28,7 +28,7 @@ type Role struct { func New(state *state.RuntimeState, config config.HostConfig) *Role { return &Role{ - client: newClient(config.Domain, config.LocalAddress), + client: newClient(config.Domain, config.IpAddress), state: state, config: config, } @@ -87,7 +87,7 @@ func (r *Role) onCallback(w http.ResponseWriter, req *http.Request) { func (r *Role) getInternal() (types.HostState, error) { return types.HostState{ Domains: r.internalDomains, - Endpoint: r.config.IpAddress, + Endpoint: r.state.Self.Address, Name: r.state.Self.Name, }, nil }