#Go monorepo: Only rebuilding the binary whose dependencies have changed

1 messages · Page 1 of 1 (latest)

void shuttle
#

Hey,

I have a monorepo, where I have a couple of Go services. One such service, produces 3 binaries lets assume X, Y and Z.
X imports A and B
Y imports C and D
Z imports A , C and D

A, B, C and D are packges within a pkg folder.

Now, I want to build a Docker/Dagger pipeline(using multi-stage build and stuff) where in if lets say there is some change in C then only Y and Z gets re-built and not A.
With Docker, the challenge is in stage 2 when I build the binary I do: COPY . .. This step is after I have copied go.mod and go.sum files and downloaded the dependencies.

So the bottle neck is, when I change C, the underlying container engine(Docker or Dagger) thinks some file has changed, and re-builds all the 3 binaries.

Is this a clever way this can be avoided?