diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/README.md b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/README.md index fb50cbadf93..0cc36398c2a 100644 --- a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/README.md +++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/README.md @@ -34,14 +34,49 @@ dataproxy-sdk cpp version, used for sending data to dataproxy ## Build -Go to the dataproxy-sdk-cpp root, and run +There are two ways to build dataproxy-sdk-cpp: -``` -./build_third_party.sh +### Method 1: Native Build + +Go to the `dataproxy-sdk-cpp` directory, and run: +```bash +./build_third_party.sh ./build.sh ``` +### Method 2: Docker Build + +**Prerequisites for Docker build:** +- Docker installed on your system + +This method uses a pre-configured Docker environment with all necessary dependencies. + +Go to the `dataproxy-sdk-cpp` directory, and run: + +1. Build the Docker image: +```bash +docker build -f docker/Dockerfile -t inlong/dataproxy-cpp-compile . +``` + +2. Run the build: +```bash +docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile +``` + +Alternatively, you can navigate to the docker directory and build from there: + +```bash +cd docker +docker build -t inlong/dataproxy-cpp-compile . +cd .. +docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile +``` + +Build artifacts will be available in the `build/` and `release/` subdirectories. + +For more details about Docker build, see [docker/README-Docker.md](docker/README-Docker.md). + ## Config Parameters Refer to `release/conf/config_example.json`. diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/Dockerfile b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/Dockerfile new file mode 100644 index 00000000000..db2f8106175 --- /dev/null +++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/Dockerfile @@ -0,0 +1,110 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Use CentOS 7 as base image +FROM centos:7 + +# Set working directory +WORKDIR /dataproxy-sdk-cpp/ + +## Switch to Tencent mirror to fix CentOS 7 yum source issues +RUN sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tencent.com|g' \ + -i.bak /etc/yum.repos.d/CentOS-*.repo && \ + yum clean all && \ + yum makecache + +# Install necessary dependency packages +RUN yum update -y && \ + yum install -y \ + gcc \ + gcc-c++ \ + make \ + autoconf \ + automake \ + libtool \ + pkgconfig \ + wget \ + openssl-devel \ + zlib-devel \ + && yum clean all && rm -rf /var/cache/yum + +# Build and install SSL-enabled curl (used by Git and CMake) +ARG CURL_VERSION=7.78.0 +RUN cd /tmp && \ + wget https://curl.se/download/curl-${CURL_VERSION}.tar.gz && \ + tar -xzf curl-${CURL_VERSION}.tar.gz && \ + cd curl-${CURL_VERSION} && \ + ./configure --prefix=/usr/local --with-ssl --with-zlib && \ + make -j"$(nproc)" && \ + make install && \ + ln -sf /usr/local/bin/curl /usr/bin/curl && \ + echo "/usr/local/lib" > /etc/ld.so.conf.d/usr-local.conf && ldconfig && \ + cd / && rm -rf /tmp/curl-* + +# Verify curl SSL support +RUN curl --version + +# Build and install Git (compile from source with CURL support) +ARG GIT_VERSION=2.34.1 +RUN cd /tmp && \ + wget https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz && \ + tar -xzf v${GIT_VERSION}.tar.gz && \ + cd git-${GIT_VERSION} && \ + make configure && \ + ./configure --prefix=/usr/local --with-curl=/usr/local && \ + make -j"$(nproc)" \ + NO_GETTEXT=YesPlease \ + NO_EXPAT=YesPlease \ + NO_PERL=YesPlease \ + NO_TCLTK=YesPlease && \ + make install \ + NO_GETTEXT=YesPlease \ + NO_EXPAT=YesPlease \ + NO_PERL=YesPlease \ + NO_TCLTK=YesPlease && \ + ln -sf /usr/local/bin/git /usr/bin/git && \ + cd / && rm -rf /tmp/git-* /tmp/v${GIT_VERSION}.tar.gz + +# Verify gcc and git versions +RUN gcc --version && git --version + +# Build and install CMake using system curl +ARG CMAKE_VERSION=3.12.4 +RUN cd /tmp && \ + wget https://cmake.org/files/v3.12/cmake-${CMAKE_VERSION}.tar.gz && \ + tar -xzf cmake-${CMAKE_VERSION}.tar.gz && \ + cd cmake-${CMAKE_VERSION} && \ + ./configure --prefix=/usr/local --system-curl && \ + make -j"$(nproc)" && \ + make install && \ + ln -sf /usr/local/bin/cmake /usr/bin/cmake && \ + ln -sf /usr/local/bin/ctest /usr/bin/ctest && \ + ln -sf /usr/local/bin/cpack /usr/bin/cpack && \ + cd / && rm -rf /tmp/cmake-* + +# Verify CMake version +RUN cmake --version + +# Copy and setup build script from docker directory +COPY build_docker.sh /usr/local/bin/build_docker.sh +RUN chmod +x /usr/local/bin/build_docker.sh + +# Set entrypoint to build script +ENTRYPOINT ["/usr/local/bin/build_docker.sh"] \ No newline at end of file diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/README-Docker.md b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/README-Docker.md new file mode 100644 index 00000000000..ee5a1a8a80f --- /dev/null +++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/README-Docker.md @@ -0,0 +1,55 @@ +# DataProxy SDK C++ Docker Compile Environment + +Docker image providing GCC, CMake, and Git environment for compiling C++ dataproxy SDK. + +## Environment + +- **OS**: CentOS 7 +- **GCC**: System default (4.8.5) +- **CMake**: 3.12.4 +- **Git**: 2.34.1 +- **Curl**: 7.78.0 +- **Tools**: gcc, gcc-c++, make, autoconf, automake, libtool, pkgconfig, openssl-devel, zlib-devel + +## Build Docker Image + +Navigate to the `dataproxy-sdk-cpp/docker` directory and build the image: + +```bash +cd docker +docker build -t inlong/dataproxy-cpp-compile . +``` + +## Usage + +### Basic Usage + +Run from the `dataproxy-sdk-cpp` directory: + +```bash +docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile +``` + +### Example + +```bash +# Navigate to the dataproxy-sdk-cpp directory +cd /path/to/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp + +# Run the build +docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile +``` + +### Alternative Usage + +You can also run from any directory by specifying the full path: + +```bash +docker run -v /path/to/dataproxy-sdk-cpp:/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile +``` + +## Output + +Build artifacts will be available in the following directories of your source code: +- `build/` - CMake build directory with object files and intermediate artifacts +- `release/` - Final release artifacts and libraries \ No newline at end of file diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/build_docker.sh b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/build_docker.sh new file mode 100755 index 00000000000..c30237392c0 --- /dev/null +++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/docker/build_docker.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +set -e + +# Check if required files exist +if [ ! -f "build_third_party.sh" ]; then + echo "Error: build_third_party.sh not found in current directory" + echo "Please make sure you have mounted the source code directory correctly" + echo "Expected mount: -v /path/to/dataproxy-sdk-cpp:/dataproxy-sdk-cpp" + exit 1 +fi + +if [ ! -f "build.sh" ]; then + echo "Error: build.sh not found in current directory" + echo "Please make sure you have mounted the source code directory correctly" + echo "Expected mount: -v /path/to/dataproxy-sdk-cpp:/dataproxy-sdk-cpp" + exit 1 +fi + +echo "=== Building third party dependencies ===" +./build_third_party.sh + +echo "=== Building dataproxy-sdk-cpp ===" +./build.sh + +echo "=== Build completed successfully ===" \ No newline at end of file