feat: improve architecture detection and installation process in Dockerfile.tpl

This commit is contained in:
Simon Larsen
2025-01-22 11:11:14 +00:00
parent 0e85162b50
commit f94fbcc2ae

View File

@@ -1,36 +1,28 @@
FROM public.ecr.aws/ubuntu/ubuntu:25.04
RUN COLLECTOR_VERSION=0.117.0
ENV COLLECTOR_VERSION=0.117.0
# Get the architecture
RUN apt-get update && apt-get install -y curl bash wget
# Install gomplate
RUN ARCHITECTURE=$(uname -m)
RUN if [ $ARCHITECTURE = "aarch64" ]; then \
ARCHITECTURE="arm64"; \
elif [ $ARCHITECTURE = "x86_64" ]; then \
ARCHITECTURE="amd64"; \
RUN /bin/bash -c 'set -ex && \
ARCH=`uname -m` && \
if [ "$ARCH" == "x86_64" ]; then \
ARCHITECTURE="amd64"; \
elif [ "$ARCH" == "aarch64" ]; then \
ARCHITECTURE="arm64"; \
fi && \
echo "ARCHITECTURE: $(uname -s) $ARCHITECTURE"
RUN curl -o /usr/local/bin/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/v3.11.3/gomplate_$(uname -s)-$ARCHITECTURE
RUN chmod 755 /usr/local/bin/gomplate
# Install the collector
RUN ARCHITECTURE=$(uname -m)
RUN if [ $ARCHITECTURE = "aarch64" ]; then \
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$COLLECTOR_VERSION/otelcol_$COLLECTOR_VERSION_linux_arm64.deb && \
dpkg -i otelcol_$COLLECTOR_VERSION_linux_arm64.deb; \
elif [ $ARCHITECTURE = "x86_64" ]; then \
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$COLLECTOR_VERSION/otelcol_$COLLECTOR_VERSION_linux_amd64.deb && \
dpkg -i otelcol_$COLLECTOR_VERSION_linux_amd64.deb; \
elif [ $ARCHITECTURE = "i386" ]; then \
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$COLLECTOR_VERSION/otelcol_$COLLECTOR_VERSION_linux_386.deb && \
dpkg -i otelcol_$COLLECTOR_VERSION_linux_386.deb; \
fi
echo "Image Architecture: $ARCHITECTURE" && \
echo "ARCHITECTURE: $ARCHITECTURE" && \
curl -o /usr/local/bin/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/v3.11.3/gomplate_Linux-$ARCHITECTURE && \
echo "Downloaded gomplate" && \
chmod 755 /usr/local/bin/gomplate && \
echo "Installed gomplate" && \
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$COLLECTOR_VERSION/otelcol_$COLLECTOR_VERSION_linux_$ARCHITECTURE.deb && \
echo "Downloaded otelcol_$COLLECTOR_VERSION_linux_$ARCHITECTURE.deb" && \
dpkg -i otelcol_$COLLECTOR_VERSION_linux_$ARCHITECTURE.deb && \
echo "Installed otelcol_$COLLECTOR_VERSION_linux_$ARCHITECTURE.deb"
# Copy the configuration template file config.yaml.tpl
COPY ./OTelCollector/otel-collector-config.template.yaml /etc/otel-collector-config.template.yaml