From e9d07687f22c1989bd4c5b83a0f621dd2e4dea31 Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Tue, 26 Nov 2024 20:15:31 +1000 Subject: [PATCH] build corrosion image based on wolfi] --- Dockerfile | 15 +++++++++++++++ internal/corrosion/subscribe.go | 2 +- internal/daemon/daemon.go | 2 +- internal/machine/store/store.go | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 62d9e11d..574b7f13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,23 @@ COPY . . RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o uncloudd cmd/uncloudd/main.go +FROM alpine:latest AS corrosion-download +RUN wget -q -O /tmp/corrosion.tar.gz \ + https://github.com/psviderski/corrosion/releases/latest/download/corrosion-aarch64-unknown-linux-gnu.tar.gz \ + && tar -xzf /tmp/corrosion.tar.gz -C /tmp \ + && install /tmp/corrosion /usr/local/bin/corrosion \ + && rm /tmp/corrosion.tar.gz /tmp/corrosion + +FROM chainguard/wolfi-base:latest AS corrosion +# TODO: create uncloud user +COPY --from=corrosion-download /usr/local/bin/corrosion /usr/local/bin/corrosion + + FROM docker:27.3.1-dind RUN apk --no-cache add \ wireguard-tools +# Create system group and user 'uncloud'. +RUN addgroup -S uncloud && adduser -SHD -h /nonexistent -G uncloud -g "" uncloud COPY --from=uncloudd /go/uncloudd /usr/local/bin/uncloudd +# TODO: socat to forward uncloud.sock unix socket? CMD ["uncloudd"] diff --git a/internal/corrosion/subscribe.go b/internal/corrosion/subscribe.go index 820127cf..4f5cc1c0 100644 --- a/internal/corrosion/subscribe.go +++ b/internal/corrosion/subscribe.go @@ -191,7 +191,7 @@ func (s *Subscription) handleChangeEvents() { } slog.Info("Resubscribing to Corrosion query due to an error.", - "error", err, "id", s.id, "from_change", s.lastChangeID) + "err", err, "id", s.id, "from_change", s.lastChangeID) sub, sErr := s.resubscribe(s.ctx, s.lastChangeID) if sErr != nil { // resubscribe returns a permanent error after unsuccessful retries. diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index b2a981e2..28cba756 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -35,7 +35,7 @@ func (d *Daemon) Run(ctx context.Context) error { case <-d.machine.Started(): _, err := systemd.SdNotify(false, systemd.SdNotifyReady) if err != nil { - slog.Error("Failed to notify systemd that the daemon is ready.", "error", err) + slog.Error("Failed to notify systemd that the daemon is ready.", "err", err) } case <-ctx.Done(): } diff --git a/internal/machine/store/store.go b/internal/machine/store/store.go index 8bb7ff30..3fb0669a 100644 --- a/internal/machine/store/store.go +++ b/internal/machine/store/store.go @@ -79,7 +79,7 @@ func (s *Store) ListMachines(ctx context.Context) ([]*pb.MachineInfo, error) { return nil, fmt.Errorf("unmarshal machine info: %w", err) } if err = m.Network.Validate(); err != nil { - slog.Error("Invalid network configuration for machine in store", "id", m.Id, "error", err) + slog.Error("Invalid network configuration for machine in store", "id", m.Id, "err", err) continue } machines = append(machines, &m)