Skip to content

Commit 8afbfe5

Browse files
committed
build(chip-router): make the image build hermetic with a cmd/chip-router module
The Dockerfile deleted go.mod's replace and ran 'go mod tidy' at build time. Tidy resolves packages missing from go.mod at latest and shifts direct deps (x/sync 0.22->0.23, x/net, x/sys, x/text, x/crypto, genproto, otel 1.46->1.47 in a scratch simulation), so an image built from a pinned commit was not reproducible, and an upstream release needing a newer go than the pinned builder broke the build with no change in this repo. The router binary imports neither the framework module nor the deploy-side library, so give cmd/chip-router its own module (go.mod/go.sum checked in; versions equal to what the parent resolved) and build from those pins only: go mod download from go.mod+go.sum, then go build -mod=readonly. Same pattern as framework/leak/cmd. The library module's go.mod no longer requires the binary's dependencies.
1 parent adaba38 commit 8afbfe5

6 files changed

Lines changed: 97 additions & 29 deletions

File tree

‎framework/components/chiprouter/.changeset/v1.0.5.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
- `chip-router`: failures return `codes.Internal` (the write-service's failure code), including when no subscribers are registered or none accepted, instead of acking undelivered events
55
- `chip-router`: implement `Ping` like the write-service
66
- `chip-router`: self-contained image build (builder `golang:1.26.6`, binary no longer imports the `framework` module); bump the `chainlink-common/pkg/chipingress` pin so `PublishResult.Error` is available
7+
- `chip-router`: `cmd/chip-router` is now its own Go module with checked-in `go.mod`/`go.sum`, so the image build uses pinned dependencies only (no `replace` editing or `go mod tidy` at build time); the library module no longer requires the router binary's dependencies (grpc, cloudevents, chipingress, protobuf)

‎framework/components/chiprouter/Dockerfile‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
FROM golang:1.26.6 AS builder
22

3-
WORKDIR /src
3+
# cmd/chip-router is its own Go module (go.mod/go.sum are checked in next to
4+
# main.go), so the image builds from pinned dependencies only: no `replace`
5+
# editing and no `go mod tidy` at build time. The router binary does not import
6+
# the parent chiprouter module (the deploy-side library) or `framework`.
7+
WORKDIR /src/cmd/chip-router
48

5-
COPY . .
9+
COPY cmd/chip-router/go.mod cmd/chip-router/go.sum ./
10+
RUN go mod download
611

7-
# The module's go.mod replaces the parent framework module with ../../ (a
8-
# monorepo-dev convenience) which cannot resolve inside this build's
9-
# module-dir context, and the published framework does not compile against
10-
# this module's moby pins. The router binary no longer imports framework
11-
# (only the deploy-side library does, and it is not compiled into the
12-
# image), so drop the replace and fetch the published framework module from
13-
# the proxy for module-graph completeness only.
14-
RUN sed -i '/^replace /d' go.mod && go mod tidy && go mod download
12+
COPY cmd/chip-router/ ./
1513

1614
ARG TARGETOS=linux
1715
ARG TARGETARCH=amd64
1816
ARG CTF_LOG_LEVEL=info
1917
ENV CTF_LOG_LEVEL=${CTF_LOG_LEVEL}
2018

21-
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w" -o /out/chip-router ./cmd/chip-router
19+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -trimpath -ldflags="-s -w" -o /out/chip-router .
2220

2321
FROM gcr.io/distroless/static-debian12:nonroot
2422

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module github.com/smartcontractkit/chainlink-testing-framework/framework/components/chiprouter/cmd/chip-router
2+
3+
go 1.26.6
4+
5+
require (
6+
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.2
7+
github.com/google/uuid v1.6.0
8+
github.com/rs/zerolog v1.33.0
9+
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260915184316-2730f1867c92
10+
golang.org/x/sync v0.22.0
11+
google.golang.org/grpc v1.83.2
12+
)
13+
14+
require (
15+
github.com/mattn/go-colorable v0.1.14 // indirect
16+
github.com/mattn/go-isatty v0.0.20 // indirect
17+
go.opentelemetry.io/otel v1.46.0 // indirect
18+
go.opentelemetry.io/otel/sdk/metric v1.45.0 // indirect
19+
golang.org/x/net v0.58.0 // indirect
20+
golang.org/x/sys v0.47.0 // indirect
21+
golang.org/x/text v0.41.0 // indirect
22+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect
23+
google.golang.org/protobuf v1.36.12 // indirect
24+
)

‎framework/components/chiprouter/cmd/chip-router/go.sum‎

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎framework/components/chiprouter/go.mod‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@ go 1.26.6
55
replace github.com/smartcontractkit/chainlink-testing-framework/framework => ../../
66

77
require (
8-
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.2
9-
github.com/google/uuid v1.6.0
108
github.com/moby/moby/api v1.54.1
119
github.com/pkg/errors v0.9.1
12-
github.com/rs/zerolog v1.33.0
13-
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260915184316-2730f1867c92
1410
github.com/smartcontractkit/chainlink-testing-framework/framework v0.15.8
1511
github.com/testcontainers/testcontainers-go v0.42.0
16-
golang.org/x/sync v0.22.0
17-
google.golang.org/grpc v1.83.2
1812
)
1913

2014
require (
@@ -43,6 +37,7 @@ require (
4337
github.com/go-playground/universal-translator v0.18.1 // indirect
4438
github.com/go-playground/validator/v10 v10.26.0 // indirect
4539
github.com/go-resty/resty/v2 v2.16.3 // indirect
40+
github.com/google/uuid v1.6.0 // indirect
4641
github.com/klauspost/compress v1.18.5 // indirect
4742
github.com/leodido/go-urn v1.4.0 // indirect
4843
github.com/lufia/plan9stats v0.0.0-20240226150601-1dcf7310316a // indirect
@@ -61,6 +56,7 @@ require (
6156
github.com/opencontainers/image-spec v1.1.1 // indirect
6257
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
6358
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
59+
github.com/rs/zerolog v1.33.0 // indirect
6460
github.com/shirou/gopsutil/v4 v4.26.3 // indirect
6561
github.com/sirupsen/logrus v1.9.4 // indirect
6662
github.com/stretchr/testify v1.12.1 // indirect
@@ -77,8 +73,7 @@ require (
7773
golang.org/x/crypto v0.55.0 // indirect
7874
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 // indirect
7975
golang.org/x/net v0.58.0 // indirect
76+
golang.org/x/sync v0.22.0 // indirect
8077
golang.org/x/sys v0.47.0 // indirect
8178
golang.org/x/text v0.41.0 // indirect
82-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect
83-
google.golang.org/protobuf v1.36.12 // indirect
8479
)

‎framework/components/chiprouter/go.sum‎

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)