mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
POST /agents/:id/upgrade enqueues a self_upgrade command carrying the target platform, the sha256 the server computed over its bundled binary, and the server version. The agent downloads the replacement from the existing /api/agents/download/:platform endpoint, verifies the checksum, sanity-checks the new binary (--version), atomically swaps its own executable, reports the command result, then re-execs via syscall.Exec — no supervisor or restart plumbing required. Agents stamp main.version via ldflags at image build, expose --version, and now send version at register so node_agents.version refreshes on re-register (older agents without the field keep their stored value). The server rejects upgrades for offline nodes and for platforms with no bundled binary (linux-amd64/linux-arm64 ship in the image). Surfaces: nodes upgrade CLI, containr_nodes_upgrade MCP (confirm-gated), node-detail page button, OpenAPI. Verified live: v0.0.3 agent upgraded to v0.0.4 in place, re-registered with the new version; offline node returns 409 NODE_OFFLINE. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
55 lines
1.5 KiB
Docker
55 lines
1.5 KiB
Docker
# Build Go API binary
|
|
FROM golang:1.26-alpine AS go-builder
|
|
|
|
RUN apk add --no-cache git ca-certificates tzdata
|
|
|
|
WORKDIR /app
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
ARG VERSION=dev
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \
|
|
-ldflags "-X containr/internal/api.Version=${VERSION}" -o main cmd/server/main.go
|
|
|
|
# Node-agent binaries served by the API for SSH/bootstrap installs.
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=${VERSION}" -o /agents/containr-agent-linux-amd64 ./cmd/agent && \
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=${VERSION}" -o /agents/containr-agent-linux-arm64 ./cmd/agent
|
|
|
|
# Build embedded Better Auth runtime dependencies
|
|
FROM node:22-alpine AS auth-builder
|
|
|
|
WORKDIR /auth
|
|
|
|
COPY auth/package*.json ./
|
|
RUN npm ci --omit=dev
|
|
|
|
COPY auth/src ./src
|
|
|
|
# Final runtime image (Go API + Better Auth sidecar in one container)
|
|
FROM node:22-alpine
|
|
|
|
RUN apk --no-cache add ca-certificates tzdata wget
|
|
|
|
RUN addgroup -g 1001 -S appgroup && \
|
|
adduser -u 1001 -S appuser -G appgroup
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=go-builder /app/main ./main
|
|
COPY --from=go-builder /app/migrations_goose ./migrations_goose
|
|
COPY --from=go-builder /agents /agents
|
|
COPY --from=auth-builder /auth ./auth
|
|
|
|
RUN chown -R appuser:appgroup /app
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/health || exit 1
|
|
|
|
CMD ["./main"]
|