Skip to content

Commit 5d8da70

Browse files
authoredAug 27, 2023
perf: Optimize Dockerfile for reduced layers and size (aquasecurity#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

+12-6
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/protoc-gen-twirp@v8.1.0
12-
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
13-
RUN go install github.com/magefile/mage@v1.14.0
15+
# Install Go tools
16+
RUN go install \
17+
github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.0 \
18+
google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1 \
19+
github.com/magefile/mage@v1.14.0
1420

1521
ENV TRIVY_PROTOC_CONTAINER=true

0 commit comments

Comments
 (0)
Please sign in to comment.