Skip to content

Commit 5d8da70

Browse files
authored
perf: Optimize Dockerfile for reduced layers and size (#5038)
* Optimize Dockerfile for reduced layers and size * Optimize Dockerfile for clarity and efficiency without compromising debuggability
1 parent 1be9da7 commit 5d8da70

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Dockerfile.protoc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
FROM --platform=linux/amd64 golang:1.19
22

3-
# Install protoc (cf. http://google.github.io/proto-lens/installing-protoc.html)
3+
# Set environment variable for protoc
44
ENV PROTOC_ZIP=protoc-3.19.4-linux-x86_64.zip
5-
RUN apt-get update && apt-get install -y unzip
5+
6+
# Install unzip for protoc installation and clean up cache
7+
RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
8+
9+
# Download and install protoc
610
RUN curl --retry 5 -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/$PROTOC_ZIP \
711
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
8-
&& unzip -o $PROTOC_ZIP -d /usr/local 'include/*' \
12+
&& unzip -o $PROTOC_ZIP -d /usr/local 'include/*' \
913
&& rm -f $PROTOC_ZIP
1014

11-
RUN go install github.com/twitchtv/twirp/[email protected]
12-
RUN go install google.golang.org/protobuf/cmd/[email protected]
13-
RUN go install github.com/magefile/[email protected]
15+
# Install Go tools
16+
RUN go install \
17+
github.com/twitchtv/twirp/[email protected] \
18+
google.golang.org/protobuf/cmd/[email protected] \
19+
github.com/magefile/[email protected]
1420

1521
ENV TRIVY_PROTOC_CONTAINER=true

0 commit comments

Comments
 (0)