@@ -91,23 +91,37 @@ endif
9191# ## Protobuf ###
9292# ##############################################################################
9393
94+ usertag: =$(shell id -u) -$(shell id -g)
95+ protoImageStamp =build/proto-image-$(usertag ) .stamp
9496protoVer =0.15.3
95- protoImageName =ghcr.io/cosmos/proto-builder:$(protoVer )
96- protoImage =$(DOCKER ) run --rm -v $(CURDIR ) :/workspace --workdir /workspace $(protoImageName )
97+ protoSourceImageName =ghcr.io/cosmos/proto-builder:$(protoVer )
98+ protoImageName =$(protoSourceImageName ) -user-$(usertag )
99+ # protoUserFlags=-e HOME=/tmp \
100+ # --user=$(shell id -u):$(shell id -g) \
101+ # $(shell id -G | xargs -n1 printf -- ' --group-add %s')
102+ protoImage =$(DOCKER ) run --rm -v $(CURDIR ) :/workspace:z --workdir /workspace $(protoImageName )
103+
104+ $(protoImageStamp ) :
105+ @echo " Creating user-specific Protobuf builder image $( protoImageName) "
106+ mkdir -p build/empty
107+ $(DOCKER ) build \
108+ --build-arg NEW_UID=$(shell id -u) --build-arg SOURCE_IMAGE=$(protoSourceImageName ) \
109+ --pull --load -f proto/Dockerfile -t $(protoImageName ) build/empty
110+ @touch $(protoImageStamp )
97111
98112proto-all : proto-format proto-lint proto-gen
99113
100- proto-gen :
114+ proto-gen : $( protoImageStamp )
101115 @echo " Generating Protobuf files"
102116 @$(protoImage ) sh ./scripts/protocgen.sh
103117
104- proto-format :
118+ proto-format : $( protoImageStamp )
105119 @$(protoImage ) find ./proto -name " *.proto" -exec clang-format -i {} \;
106120
107- proto-lint :
121+ proto-lint : $( protoImageStamp )
108122 @$(protoImage ) buf lint --error-format=json ./proto
109123
110- proto-check-breaking :
124+ proto-check-breaking : $( protoImageStamp )
111125 @$(protoImage ) buf breaking --against $(PR_TARGET_REPO ) # branch=$(PR_TARGET_BRANCH),subdir=golang/cosmos
112126
113127GOGO_PROTO_URL = file://$(shell go list -m -f '{{ .Dir }}' github.com/cosmos/gogoproto)
0 commit comments