Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for running dynolog inside a docker container #166

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
30 changes: 25 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# CMAKE options
ARG USE_PROMETHEUS=OFF

FROM --platform=linux/amd64 amd64/ubuntu:20.04 AS ubuntu_build_x86
ARG USE_PROMETHEUS

# This required to avoid interactive build for tzdata
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
Expand All @@ -11,8 +16,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ninja-build \
tini \
tree \
vim \
&& rm -rf /var/lib/apt/lists/*
vim
RUN if [ "$USE_PROMETHEUS" = "ON" ]; then apt-get install -y --no-install-recommends zlib1g-dev; fi
RUN rm -rf /var/lib/apt/lists/*
# Use Rust nightly with sparse index, https://github.com/rust-lang/cargo/issues/10781
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
ENV PATH /root/.cargo/bin:$PATH
Expand All @@ -23,9 +29,11 @@ COPY . .
# Run the rust build directly
RUN cd cli && /root/.cargo/bin/cargo +nightly build --release -Z sparse-registry --target-dir build

RUN ./scripts/build.sh 2>&1 | tee build.log
RUN if [ "$USE_PROMETHEUS" = "ON" ]; then ./scripts/install-prometheus-cpp.sh; fi
RUN ./scripts/build.sh -DUSE_PROMETHEUS=${USE_PROMETHEUS} 2>&1 | tee build.log

FROM --platform=linux/amd64 rockylinux:9 AS rocky_build_x86
ARG USE_PROMETHEUS
RUN yum update -y && \
yum install -y \
make \
Expand All @@ -40,6 +48,7 @@ RUN yum update -y && \
systemd-rpm-macros \
tree \
vim
RUN if [ "$USE_PROMETHEUS" = "ON" ]; then yum install -y zlib-devel; fi
RUN dnf --enablerepo=crb install -y ninja-build
# Use Rust nightly with sparse index, https://github.com/rust-lang/cargo/issues/10781
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
Expand All @@ -51,4 +60,15 @@ COPY . .
# Run the rust build directly
RUN cd cli && /root/.cargo/bin/cargo +nightly build --release -Z sparse-registry --target-dir build

RUN ./scripts/build.sh 2>&1 | tee build.log
RUN if [ "$USE_PROMETHEUS" = "ON" ]; then ./scripts/install-prometheus-cpp.sh; fi
RUN ./scripts/build.sh -DUSE_PROMETHEUS=${USE_PROMETHEUS} 2>&1 | tee build.log

# Image for running dynolog daemon
FROM --platform=linux/amd64 amd64/ubuntu:20.04 AS docker_dynolog
ARG USE_PROMETHEUS
RUN apt-get update && apt-get install -y --no-install-recommends tini
COPY --from=ubuntu_build_x86 /workspace/dynolog/build/bin/dynolog /root/dynolog
ENTRYPOINT ["/usr/bin/tini", "--", "/root/dynolog"]



17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
docker-dynolog:
container_name: dynolog
command: --use_prometheus true
network_mode: host
build:
context: ./
target: docker_dynolog
args:
- USE_PROMETHEUS=ON
volumes:
- /proc:/proc





1 change: 1 addition & 0 deletions hbt/src/perf_event/CpuEventsGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <fmt/ranges.h>
#include <iostream>
#include <vector>
#include <utility>

// If this version of linux/perf_event.h does not provide,
// then add it.
Expand Down
17 changes: 17 additions & 0 deletions scripts/install-prometheus-cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -eux -o pipefail

DOWNLOAD_DIR=$(mktemp -d)
PROMETHEUS_CPP_VERSION="${PROMETHEUS_CPP_VERSION:-v1.1.0}"

curl "https://github.com/jupp0r/prometheus-cpp/releases/download/${PROMETHEUS_CPP_VERSION}/prometheus-cpp-with-submodules.tar.gz" -o "${DOWNLOAD_DIR}/prometheus-cpp.tar.gz" -L
tar -xf "${DOWNLOAD_DIR}/prometheus-cpp.tar.gz" -C "${DOWNLOAD_DIR}"

mkdir "${DOWNLOAD_DIR}/prometheus-cpp-with-submodules/build"

pushd "${DOWNLOAD_DIR}/prometheus-cpp-with-submodules/build"
cmake -DENABLE_PUSH=OFF -DENABLE_TESTING=OFF ..
cmake --build .
cmake --install .
popd