WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 356c4bb

Browse files
committed
[INLONG-12014][SDK] Add C++ Dataproxy SDK compile Dockerfile
1 parent f54b557 commit 356c4bb

File tree

4 files changed

+247
-3
lines changed

4 files changed

+247
-3
lines changed

inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,49 @@ dataproxy-sdk cpp version, used for sending data to dataproxy
3434

3535
## Build
3636

37-
Go to the dataproxy-sdk-cpp root, and run
37+
There are two ways to build dataproxy-sdk-cpp:
3838

39-
```
40-
./build_third_party.sh
39+
### Method 1: Native Build
40+
41+
Go to the `dataproxy-sdk-cpp` directory, and run:
4142

43+
```bash
44+
./build_third_party.sh
4245
./build.sh
4346
```
4447

48+
### Method 2: Docker Build
49+
50+
**Prerequisites for Docker build:**
51+
- Docker installed on your system
52+
53+
This method uses a pre-configured Docker environment with all necessary dependencies.
54+
55+
Go to the `dataproxy-sdk-cpp` directory, and run:
56+
57+
1. Build the Docker image:
58+
```bash
59+
docker build -f docker/Dockerfile -t inlong/dataproxy-cpp-compile .
60+
```
61+
62+
2. Run the build:
63+
```bash
64+
docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile
65+
```
66+
67+
Alternatively, you can navigate to the docker directory and build from there:
68+
69+
```bash
70+
cd docker
71+
docker build -t inlong/dataproxy-cpp-compile .
72+
cd ..
73+
docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile
74+
```
75+
76+
Build artifacts will be available in the `build/` and `release/` subdirectories.
77+
78+
For more details about Docker build, see [docker/README-Docker.md](docker/README-Docker.md).
79+
4580
## Config Parameters
4681

4782
Refer to `release/conf/config_example.json`.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# Use CentOS 7 as base image
21+
FROM centos:7
22+
23+
# Set working directory
24+
WORKDIR /dataproxy-sdk-cpp/
25+
26+
## Switch to Tencent mirror to fix CentOS 7 yum source issues
27+
RUN sed -e 's|^mirrorlist=|#mirrorlist=|g' \
28+
-e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tencent.com|g' \
29+
-i.bak /etc/yum.repos.d/CentOS-*.repo && \
30+
yum clean all && \
31+
yum makecache
32+
33+
# Install necessary dependency packages
34+
RUN yum update -y && \
35+
yum install -y \
36+
gcc \
37+
gcc-c++ \
38+
make \
39+
autoconf \
40+
automake \
41+
libtool \
42+
pkgconfig \
43+
wget \
44+
openssl-devel \
45+
zlib-devel \
46+
&& yum clean all && rm -rf /var/cache/yum
47+
48+
# Build and install SSL-enabled curl (used by Git and CMake)
49+
ARG CURL_VERSION=7.78.0
50+
RUN cd /tmp && \
51+
wget https://curl.se/download/curl-${CURL_VERSION}.tar.gz && \
52+
tar -xzf curl-${CURL_VERSION}.tar.gz && \
53+
cd curl-${CURL_VERSION} && \
54+
./configure --prefix=/usr/local --with-ssl --with-zlib && \
55+
make -j"$(nproc)" && \
56+
make install && \
57+
ln -sf /usr/local/bin/curl /usr/bin/curl && \
58+
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr-local.conf && ldconfig && \
59+
cd / && rm -rf /tmp/curl-*
60+
61+
# Verify curl SSL support
62+
RUN curl --version
63+
64+
# Build and install Git (compile from source with CURL support)
65+
ARG GIT_VERSION=2.34.1
66+
RUN cd /tmp && \
67+
wget https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz && \
68+
tar -xzf v${GIT_VERSION}.tar.gz && \
69+
cd git-${GIT_VERSION} && \
70+
make configure && \
71+
./configure --prefix=/usr/local --with-curl=/usr/local && \
72+
make -j"$(nproc)" \
73+
NO_GETTEXT=YesPlease \
74+
NO_EXPAT=YesPlease \
75+
NO_PERL=YesPlease \
76+
NO_TCLTK=YesPlease && \
77+
make install \
78+
NO_GETTEXT=YesPlease \
79+
NO_EXPAT=YesPlease \
80+
NO_PERL=YesPlease \
81+
NO_TCLTK=YesPlease && \
82+
ln -sf /usr/local/bin/git /usr/bin/git && \
83+
cd / && rm -rf /tmp/git-* /tmp/v${GIT_VERSION}.tar.gz
84+
85+
# Verify gcc and git versions
86+
RUN gcc --version && git --version
87+
88+
# Build and install CMake using system curl
89+
ARG CMAKE_VERSION=3.12.4
90+
RUN cd /tmp && \
91+
wget https://cmake.org/files/v3.12/cmake-${CMAKE_VERSION}.tar.gz && \
92+
tar -xzf cmake-${CMAKE_VERSION}.tar.gz && \
93+
cd cmake-${CMAKE_VERSION} && \
94+
./configure --prefix=/usr/local --system-curl && \
95+
make -j"$(nproc)" && \
96+
make install && \
97+
ln -sf /usr/local/bin/cmake /usr/bin/cmake && \
98+
ln -sf /usr/local/bin/ctest /usr/bin/ctest && \
99+
ln -sf /usr/local/bin/cpack /usr/bin/cpack && \
100+
cd / && rm -rf /tmp/cmake-*
101+
102+
# Verify CMake version
103+
RUN cmake --version
104+
105+
# Copy and setup build script from docker directory
106+
COPY build_docker.sh /usr/local/bin/build_docker.sh
107+
RUN chmod +x /usr/local/bin/build_docker.sh
108+
109+
# Set entrypoint to build script
110+
ENTRYPOINT ["/usr/local/bin/build_docker.sh"]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# DataProxy SDK C++ Docker Compile Environment
2+
3+
Docker image providing GCC, CMake, and Git environment for compiling C++ dataproxy SDK.
4+
5+
## Environment
6+
7+
- **OS**: CentOS 7
8+
- **GCC**: System default (4.8.5)
9+
- **CMake**: 3.12.4
10+
- **Git**: 2.34.1
11+
- **Curl**: 7.78.0
12+
- **Tools**: gcc, gcc-c++, make, autoconf, automake, libtool, pkgconfig, openssl-devel, zlib-devel
13+
14+
## Build Docker Image
15+
16+
Navigate to the `dataproxy-sdk-cpp/docker` directory and build the image:
17+
18+
```bash
19+
cd docker
20+
docker build -t inlong/dataproxy-cpp-compile .
21+
```
22+
23+
## Usage
24+
25+
### Basic Usage
26+
27+
Run from the `dataproxy-sdk-cpp` directory:
28+
29+
```bash
30+
docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile
31+
```
32+
33+
### Example
34+
35+
```bash
36+
# Navigate to the dataproxy-sdk-cpp directory
37+
cd /path/to/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp
38+
39+
# Run the build
40+
docker run -v $(pwd):/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile
41+
```
42+
43+
### Alternative Usage
44+
45+
You can also run from any directory by specifying the full path:
46+
47+
```bash
48+
docker run -v /path/to/dataproxy-sdk-cpp:/dataproxy-sdk-cpp inlong/dataproxy-cpp-compile
49+
```
50+
51+
## Output
52+
53+
Build artifacts will be available in the following directories of your source code:
54+
- `build/` - CMake build directory with object files and intermediate artifacts
55+
- `release/` - Final release artifacts and libraries
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
set -e
22+
23+
# Check if required files exist
24+
if [ ! -f "build_third_party.sh" ]; then
25+
echo "Error: build_third_party.sh not found in current directory"
26+
echo "Please make sure you have mounted the source code directory correctly"
27+
echo "Expected mount: -v /path/to/dataproxy-sdk-cpp:/dataproxy-sdk-cpp"
28+
exit 1
29+
fi
30+
31+
if [ ! -f "build.sh" ]; then
32+
echo "Error: build.sh not found in current directory"
33+
echo "Please make sure you have mounted the source code directory correctly"
34+
echo "Expected mount: -v /path/to/dataproxy-sdk-cpp:/dataproxy-sdk-cpp"
35+
exit 1
36+
fi
37+
38+
echo "=== Building third party dependencies ==="
39+
./build_third_party.sh
40+
41+
echo "=== Building dataproxy-sdk-cpp ==="
42+
./build.sh
43+
44+
echo "=== Build completed successfully ==="

0 commit comments

Comments
 (0)