Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions images/Dockerfile.build_layer
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@ ARG FILE_SUFFIX

# Install dependencies
RUN apt-get update
RUN apt-get install -y zip binutils
RUN apt-get install -y zip binutils wget tar xz-utils
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

package wget should have version pinned (...read more)

When using apt-get install, pin the version to avoid unwanted upgrades and undefined behavior.

View in Datadog  Leave us feedback  Documentation


# UPX installation directly from GitHub
ENV UPX_VERSION=5.0.0
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
ARCH_NAME="amd64"; \
elif [ "$ARCH" = "aarch64" ]; then \
ARCH_NAME="arm64"; \
fi && \
wget https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-${ARCH_NAME}_linux.tar.xz && \
tar -xf upx-${UPX_VERSION}-${ARCH_NAME}_linux.tar.xz && \
mv upx-${UPX_VERSION}-${ARCH_NAME}_linux/upx /usr/local/bin/ && \
rm -rf upx-${UPX_VERSION}-${ARCH_NAME}_linux upx-${UPX_VERSION}-${ARCH_NAME}_linux.tar.xz

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

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

RUN mkdir /extensions
WORKDIR /extensions
Expand Down
6 changes: 0 additions & 6 deletions images/Dockerfile.go_agent.alpine.compile
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ RUN /usr/lib/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/datad
# Strip the binary to reduce size
RUN strip datadog-agent

# Compress the binary with UPX, but only if the architecture is x86_64
RUN arch="$(uname -m)"; \
if [ "${arch}" = 'x86_64' ]; then \
apk add --no-cache upx=3.96-r1 && upx -1 datadog-agent; \
fi;

# Use the smallest image possible
FROM scratch
COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent /
Expand Down
3 changes: 0 additions & 3 deletions images/Dockerfile.go_agent.compile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ RUN /usr/local/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/dat
# Strip the binary to reduce size
RUN strip datadog-agent

# Compress the binary with UPX, but only if the architecture is x86_64
RUN if [ "$arch" = "x86_64" ]; then apt-get install -y upx=3.96-r0 && upx -1 /datadog-agent; fi

# Use the smallest image possible
FROM scratch
COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent /
Expand Down
Loading