From 6cfc882294c49d7f45ea9acf06c545d012a85930 Mon Sep 17 00:00:00 2001 From: zynfly Date: Wed, 28 Aug 2024 10:00:00 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=B7=BB=E5=8A=A0]opcua=20exporter=20?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 6 ++++- opcua-expoter/Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 opcua-expoter/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 4585da4..db28da7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,4 +28,8 @@ services: - etcd - prometheus node-exporter: - build: docker/node_exporter \ No newline at end of file + build: docker/node_exporter + opcua-exporter: + build: opcua-expoter + volumes: + - ./data:/data \ No newline at end of file diff --git a/opcua-expoter/Dockerfile b/opcua-expoter/Dockerfile new file mode 100644 index 0000000..dbf2bc5 --- /dev/null +++ b/opcua-expoter/Dockerfile @@ -0,0 +1,47 @@ +FROM openeuler/openeuler:24.03 AS dev + +RUN dnf update -y && \ + dnf install -y git gcc g++ gdb make autoconf automake curl zip unzip tar &&\ + dnf clean all && \ + rm -rf /var/cache/dnf/* + +ENV VCPKG_ROOT="/vcpkg" + +RUN curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.27.2/cmake-3.27.2-linux-x86_64.sh -o cmake_install.sh && \ + chmod +x cmake_install.sh && \ + ./cmake_install.sh --prefix=/usr/local --skip-license && \ + rm -rf cmake_install.sh + +RUN curl -fsSL https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip -o ninja-linux.zip && \ + unzip ninja-linux.zip && \ + rm -rf ninja-linux.zip && \ + mv ninja /usr/local/bin/ && \ + chmod +x /usr/local/bin/ninja + +RUN curl -fsSL https://github.com/microsoft/vcpkg-tool/releases/download/2024-07-10/vcpkg-glibc -o /usr/local/bin/vcpkg && \ + chmod +x /usr/local/bin/vcpkg && \ + git clone -b 2024.07.12 --depth 1 https://github.com/microsoft/vcpkg /vcpkg + +RUN vcpkg install civetweb prometheus-cpp spdlog nlohmann-json yaml-cpp open62541 --clean-after-build + +FROM dev AS build + +RUN mkdir /app + +WORKDIR /app + +COPY . /app + +RUN mkdir build && \ + cd build && \ + cmake .. -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -G Ninja && \ + cmake --build . --target opcua_exporter + +FROM openeuler/openeuler:24.03 + +RUN mkdir /data + +COPY --from=build /app/build/opcua_exporter /usr/local/bin + + +CMD [ "opcua_exporter", "/data/opcua/opcua.yaml" ] \ No newline at end of file