Skip to content

Commit 13fcc07

Browse files
committed
Add dockerized target for building proto files
Makes it possible to build api files without contaminating the host system. Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
1 parent a2eea2b commit 13fcc07

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ FORCE:
7979

8080
build-proto: $(PROTO_GOFILES)
8181

82+
.PHONY: build-proto-dockerized
83+
build-proto-dockerized:
84+
$(Q)docker build --build-arg ARTIFACTS="$(dir $(PROTO_GOFILES))" --target final \
85+
--output type=local,dest=$(RESOLVED_PWD) \
86+
-f hack/Dockerfile.buildproto .
87+
$(Q)tar xf artifacts.tgz && rm -f artifacts.tgz
88+
8289
build-plugins: $(PLUGINS)
8390

8491
build-check:

hack/Dockerfile.buildproto

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright The containerd Authors.
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG GO_VERSION=1.24
16+
ARG BASE_DEBIAN_DISTRO="bookworm"
17+
18+
FROM golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO} AS builder
19+
ARG ARTIFACTS
20+
21+
WORKDIR /go/src
22+
23+
RUN apt-get update && apt-get install -y unzip
24+
25+
RUN --mount=type=cache,target=/go/pkg/mod/ \
26+
--mount=src=.,target=. \
27+
make install-protoc-dependencies install-ttrpc-plugin install-wasm-plugin install-protoc
28+
29+
RUN --mount=type=cache,target=/go/pkg/mod/ \
30+
--mount=src=.,target=.,rw=true \
31+
make build-proto && \
32+
tar czf /artifacts.tgz ${ARTIFACTS}
33+
34+
FROM scratch AS final
35+
36+
COPY --from=builder /artifacts.tgz .

0 commit comments

Comments
 (0)