diff --git a/.gitignore b/.gitignore index f18e914..7339f80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ .idea venv/ +.venv +/container/grafana/* +/container/loki/* +/container/prometheus/* diff --git a/build-lgtm.sh b/build-lgtm.sh new file mode 100755 index 0000000..99bae72 --- /dev/null +++ b/build-lgtm.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +RELEASE=${1:-dev} + +docker buildx build -f docker/Dockerfile docker --tag grafana/otel-lgtm:${RELEASE} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 42cd1f6..5e57cbb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,34 +6,40 @@ ENV TEMPO_VERSION="2.4.1" ENV LOKI_VERSION="2.9.6" ENV OPENTELEMETRY_COLLECTOR_VERSION="0.97.0" +# TARGETARCH is automatically detected and set by the Docker daemon during the build process. If the build starts +# on an amd64 architecture, than the TARGETARCH will be set to `amd64`. +# More details on the variables can be found here: https://docs.docker.com/desktop/extensions-sdk/extensions/multi-arch/ +ARG TARGETARCH +ENV TARGETARCH=${TARGETARCH} + RUN mkdir /otel-lgtm WORKDIR /otel-lgtm -RUN yum install -y unzip jq +RUN yum install -y unzip jq procps -RUN curl -sOL https://dl.grafana.com/oss/release/grafana-$GRAFANA_VERSION.linux-amd64.tar.gz && \ - tar xfz grafana-$GRAFANA_VERSION.linux-amd64.tar.gz && \ - rm grafana-$GRAFANA_VERSION.linux-amd64.tar.gz +RUN curl -sOL https://dl.grafana.com/oss/release/grafana-$GRAFANA_VERSION.linux-${TARGETARCH}.tar.gz && \ + tar xfz grafana-$GRAFANA_VERSION.linux-${TARGETARCH}.tar.gz && \ + rm grafana-$GRAFANA_VERSION.linux-${TARGETARCH}.tar.gz -RUN curl -sOL https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz && \ - tar xfz prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz && \ - mv prometheus-$PROMETHEUS_VERSION.linux-amd64 prometheus-$PROMETHEUS_VERSION && \ - rm prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz +RUN curl -sOL https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-${TARGETARCH}.tar.gz && \ + tar xfz prometheus-$PROMETHEUS_VERSION.linux-${TARGETARCH}.tar.gz && \ + mv prometheus-$PROMETHEUS_VERSION.linux-${TARGETARCH} prometheus-$PROMETHEUS_VERSION && \ + rm prometheus-$PROMETHEUS_VERSION.linux-${TARGETARCH}.tar.gz -RUN curl -sOL https://github.com/grafana/tempo/releases/download/v$TEMPO_VERSION/tempo_${TEMPO_VERSION}_linux_amd64.tar.gz && \ +RUN curl -sOL https://github.com/grafana/tempo/releases/download/v$TEMPO_VERSION/tempo_${TEMPO_VERSION}_linux_${TARGETARCH}.tar.gz && \ mkdir tempo-$TEMPO_VERSION/ && \ - tar xfz tempo_${TEMPO_VERSION}_linux_amd64.tar.gz -C tempo-$TEMPO_VERSION/ && \ - rm tempo_${TEMPO_VERSION}_linux_amd64.tar.gz + tar xfz tempo_${TEMPO_VERSION}_linux_${TARGETARCH}.tar.gz -C tempo-$TEMPO_VERSION/ && \ + rm tempo_${TEMPO_VERSION}_linux_${TARGETARCH}.tar.gz -RUN curl -sOL https://github.com/grafana/loki/releases/download/v$LOKI_VERSION/loki-linux-amd64.zip && \ +RUN curl -sOL https://github.com/grafana/loki/releases/download/v$LOKI_VERSION/loki-linux-${TARGETARCH}.zip && \ mkdir loki-$LOKI_VERSION && \ - unzip loki-linux-amd64 -d loki-$LOKI_VERSION/ && \ - rm loki-linux-amd64.zip + unzip loki-linux-${TARGETARCH} -d loki-$LOKI_VERSION/ && \ + rm loki-linux-${TARGETARCH}.zip -RUN curl -sOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$OPENTELEMETRY_COLLECTOR_VERSION/otelcol-contrib_${OPENTELEMETRY_COLLECTOR_VERSION}_linux_amd64.tar.gz && \ +RUN curl -sOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$OPENTELEMETRY_COLLECTOR_VERSION/otelcol-contrib_${OPENTELEMETRY_COLLECTOR_VERSION}_linux_${TARGETARCH}.tar.gz && \ mkdir otelcol-contrib-$OPENTELEMETRY_COLLECTOR_VERSION && \ - tar xfz otelcol-contrib_${OPENTELEMETRY_COLLECTOR_VERSION}_linux_amd64.tar.gz -C otelcol-contrib-$OPENTELEMETRY_COLLECTOR_VERSION/ && \ - rm otelcol-contrib_${OPENTELEMETRY_COLLECTOR_VERSION}_linux_amd64.tar.gz + tar xfz otelcol-contrib_${OPENTELEMETRY_COLLECTOR_VERSION}_linux_${TARGETARCH}.tar.gz -C otelcol-contrib-$OPENTELEMETRY_COLLECTOR_VERSION/ && \ + rm otelcol-contrib_${OPENTELEMETRY_COLLECTOR_VERSION}_linux_${TARGETARCH}.tar.gz COPY prometheus.yaml . COPY run-prometheus.sh . diff --git a/docker/run-loki.sh b/docker/run-loki.sh index a632025..8e9322d 100755 --- a/docker/run-loki.sh +++ b/docker/run-loki.sh @@ -1,3 +1,3 @@ #!/bin/bash -./loki-$LOKI_VERSION/loki-linux-amd64 --config.file=./loki-config.yaml > /dev/null 2>&1 +./loki-$LOKI_VERSION/loki-linux-${TARGETARCH} --config.file=./loki-config.yaml > /dev/null 2>&1 diff --git a/docker/run-prometheus.sh b/docker/run-prometheus.sh index 369d098..08711ff 100755 --- a/docker/run-prometheus.sh +++ b/docker/run-prometheus.sh @@ -4,4 +4,5 @@ --web.enable-remote-write-receiver \ --enable-feature=exemplar-storage \ --enable-feature=native-histograms \ + --storage.tsdb.path=/data/prometheus \ --config.file=./prometheus.yaml > /dev/null 2>&1 diff --git a/run-lgtm.sh b/run-lgtm.sh index 176d67b..203fe8b 100755 --- a/run-lgtm.sh +++ b/run-lgtm.sh @@ -1,3 +1,16 @@ #!/bin/bash -docker run -p 3000:3000 -p 4317:4317 -p 4318:4318 --rm -ti grafana/otel-lgtm +RELEASE=${1:-dev} + +docker run \ + --name lgtm \ + -p 3000:3000 \ + -p 4317:4317 \ + -p 4318:4318 \ + --rm \ + -ti \ + -v $PWD/container/grafana:/data/grafana \ + -v $PWD/container/prometheus:/data/prometheus \ + -v $PWD/container/loki:/loki \ + -e GF_PATHS_DATA=/data/grafana \ + localhost/grafana/otel-lgtm:${RELEASE} \ No newline at end of file