Skip to content

Commit 35a7dbc

Browse files
authored
chore: fix upx compression (#583)
* install upx in runner * remove installation from ci image * remove compression on compilation * compile on layer building
1 parent f0c7b8b commit 35a7dbc

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

images/Dockerfile.build_layer

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,26 @@ ARG FILE_SUFFIX
44

55
# Install dependencies
66
RUN apt-get update
7-
RUN apt-get install -y zip binutils
7+
RUN apt-get install -y zip binutils wget tar xz-utils
8+
9+
# UPX installation directly from GitHub
10+
ENV UPX_VERSION=5.0.0
11+
RUN ARCH=$(uname -m) && \
12+
if [ "$ARCH" = "x86_64" ]; then \
13+
ARCH_NAME="amd64"; \
14+
elif [ "$ARCH" = "aarch64" ]; then \
15+
ARCH_NAME="arm64"; \
16+
fi && \
17+
wget https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-${ARCH_NAME}_linux.tar.xz && \
18+
tar -xf upx-${UPX_VERSION}-${ARCH_NAME}_linux.tar.xz && \
19+
mv upx-${UPX_VERSION}-${ARCH_NAME}_linux/upx /usr/local/bin/ && \
20+
rm -rf upx-${UPX_VERSION}-${ARCH_NAME}_linux upx-${UPX_VERSION}-${ARCH_NAME}_linux.tar.xz
821

922
# Copy Go Agent binary
1023
COPY .binaries/datadog-agent-$FILE_SUFFIX /datadog-agent-go
1124

12-
# UPX compress on x86_64
13-
RUN if [ "$PLATFORM" = "x86_64" ]; then apt-get install -y upx=3.96-r0 && upx -1 /datadog-agent-go; fi
25+
# UPX compress
26+
RUN upx -1 /datadog-agent-go
1427

1528
RUN mkdir /extensions
1629
WORKDIR /extensions

images/Dockerfile.go_agent.alpine.compile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ RUN /usr/lib/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/datad
4848
# Strip the binary to reduce size
4949
RUN strip datadog-agent
5050

51-
# Compress the binary with UPX, but only if the architecture is x86_64
52-
RUN arch="$(uname -m)"; \
53-
if [ "${arch}" = 'x86_64' ]; then \
54-
apk add --no-cache upx=3.96-r1 && upx -1 datadog-agent; \
55-
fi;
56-
5751
# Use the smallest image possible
5852
FROM scratch
5953
COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent /

images/Dockerfile.go_agent.compile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ RUN /usr/local/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/dat
5050
# Strip the binary to reduce size
5151
RUN strip datadog-agent
5252

53-
# Compress the binary with UPX, but only if the architecture is x86_64
54-
RUN if [ "$arch" = "x86_64" ]; then apt-get install -y upx=3.96-r0 && upx -1 /datadog-agent; fi
55-
5653
# Use the smallest image possible
5754
FROM scratch
5855
COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent /

0 commit comments

Comments
 (0)