Skip to content

Commit 5ee9e8d

Browse files
committed
pfs: build in centos7
Signed-off-by: Cyber-SiKu <[email protected]>
1 parent 5a9e3f6 commit 5ee9e8d

File tree

2 files changed

+279
-47
lines changed

2 files changed

+279
-47
lines changed

docker/curve/1.2/centos7/Dockerfile

+274-44
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,278 @@
11
FROM centos:7 as fiu
22
LABEL maintainer="Cyber-SiKu <[email protected]>"
3-
# ADD https://mirrors.163.com/.help/CentOS7-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo
4-
RUN yum clean all && yum makecache \
5-
&& yum install -y wget \
6-
gcc \
7-
python3 \
8-
make \
9-
&& wget https://github.com/albertito/libfiu/archive/refs/tags/1.00.tar.gz \
10-
&& tar -xzvf 1.00.tar.gz \
11-
&& cd libfiu-1.00 \
12-
&& make && make install
3+
RUN yum install -y \
4+
centos-release-scl \
5+
centos-release-scl-rh&& \
6+
yum update -y && \
7+
yum clean all
8+
ADD https://curve-build.nos-eastchina1.126.net/libfiu-1.00.tar.gz /
9+
RUN yum install -y \
10+
devtoolset-9-gcc \
11+
devtoolset-9-gcc-c++ \
12+
devtoolset-9-libstdc++-devel \
13+
devtoolset-9-make \
14+
python3 && \
15+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
16+
source /etc/bashrc && \
17+
tar -xzvf libfiu-1.00.tar.gz && rm libfiu-1.00.tar.gz && \
18+
cd libfiu-1.00 && \
19+
make && make install
1320

14-
FROM centos:7 as builder
15-
16-
COPY --from=fiu /usr/local/include/fiu*.h /usr/local/include/
17-
COPY --from=fiu /usr/local/lib/ /usr/local/lib
18-
RUN yum clean all && yum makecache \
19-
&& yum install -y wget \
20-
make \
21-
patch \
22-
gcc \
23-
gcc-c++ \
24-
clang \
25-
zlib-devel \
26-
openssl-devel \
27-
libuuid-devel \
28-
libnl3-devel \
29-
libcurl-devel \
30-
python-devel \
21+
FROM centos:7 AS curve-builder
22+
LABEL maintainer="Cyber-SiKu <[email protected]>"
23+
COPY --from=fiu /usr/local/include/fiu*.h /usr/include/
24+
COPY --from=fiu /usr/local/lib/ /usr/lib
25+
ARG TARGETARCH
26+
RUN yum install -y \
27+
wget \
28+
patch \
29+
zlib-devel \
30+
openssl-devel \
31+
libuuid-devel \
32+
libnl3-devel \
33+
libcurl-devel \
34+
python-devel \
35+
libunwind-devel \
36+
fuse3-devel \
37+
sudo \
38+
lz4-devel \
39+
snappy-devel \
40+
centos-release-scl \
41+
centos-release-scl-rh \
42+
which && \
43+
if [ "$TARGETARCH" = "amd64" ]; then \
44+
BAZEL_ARCH=x86_64; \
45+
elif [ "$TARGETARCH" = "arm64" ]; then \
46+
BAZEL_ARCH=arm64; \
47+
else \
48+
BAZEL_ARCH=x86_64; \
49+
fi && \
50+
wget https://curve-build.nos-eastchina1.126.net/bazelbuild/bazelisk/bazelisk-linux-${BAZEL_ARCH} && \
51+
mv bazelisk-linux-${BAZEL_ARCH} /usr/bin/bazelisk && \
52+
ln -s /usr/bin/bazelisk /usr/bin/bazel && \
53+
wget https://curve-build.nos-eastchina1.126.net/bazelbuild/4.2.2/bazel-4.2.2-linux-${BAZEL_ARCH} && \
54+
mkdir -p /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-${BAZEL_ARCH}/bin && \
55+
mv bazel-4.2.2-linux-${BAZEL_ARCH} /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-${BAZEL_ARCH}/bin/bazel && \
56+
wget https://curve-build.nos-eastchina1.126.net/bazelbuild/0.17.2/bazel-0.17.2-linux-${BAZEL_ARCH} && \
57+
mkdir -p /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-${BAZEL_ARCH}/bin && \
58+
mv bazel-0.17.2-linux-${BAZEL_ARCH} /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-${BAZEL_ARCH}/bin/bazel && \
59+
chmod +x /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-${BAZEL_ARCH}/bin/bazel /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-${BAZEL_ARCH}/bin/bazel /usr/bin/bazel /usr/bin/bazelisk && \
60+
if [ "$TARGETARCH" = "arm64" ]; then \
61+
yum install -y epel-release && \
62+
yum install -y \
63+
rh-git227-git \
64+
python2-pip \
3165
python-setuptools \
32-
python3-devel \
33-
python3-setuptools \
34-
python3-wheel \
35-
libunwind-devel \
36-
sudo \
37-
&& wget https://curve-build.nos-eastchina1.126.net/bazelbuild/bazelisk/bazelisk-linux-amd64 \
38-
&& mv bazelisk-linux-amd64 /usr/bin/bazelisk \
39-
&& ln -s /usr/bin/bazelisk /usr/bin/bazel \
40-
&& wget https://curve-build.nos-eastchina1.126.net/bazelbuild/4.2.2/bazel-4.2.2-linux-x86_64 \
41-
&& mkdir -p /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-x86_64/bin \
42-
&& mv bazel-4.2.2-linux-x86_64 /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-x86_64/bin/bazel \
43-
&& wget https://curve-build.nos-eastchina1.126.net/bazelbuild/0.17.2/bazel-0.17.2-linux-x86_64\
44-
&& mkdir -p /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-x86_64/bin \
45-
&& mv bazel-0.17.2-linux-x86_64 /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-x86_64/bin/bazel \
46-
&& chmod +x /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-x86_64/bin/bazel /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-x86_64/bin/bazel /usr/bin/bazel /usr/bin/bazelisk \
47-
&& yum install -y https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm \
48-
&& yum install -y git
66+
python2-wheel \
67+
java-1.8.0-openjdk \
68+
java-1.8.0-openjdk-devel && \
69+
echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.aarch64" >> /etc/bashrc && \
70+
echo "source /opt/rh/rh-git227/enable" >> /etc/bashrc && \
71+
echo "source /opt/rh/httpd24/enable" >> /etc/bashrc; \
72+
else \
73+
yum install -y \
74+
sclo-git212 \
75+
python27-python-pip \
76+
python27-python-setuptools \
77+
python27-python-wheel && \
78+
echo "source /opt/rh/sclo-git212/enable" >> /etc/bashrc && \
79+
echo "source /opt/rh/python27/enable" >> /etc/bashrc; \
80+
fi && \
81+
yum install -y \
82+
devtoolset-9-gcc \
83+
devtoolset-9-gcc-c++ \
84+
devtoolset-9-libstdc++-devel \
85+
devtoolset-9-make \
86+
llvm-toolset-7.0-cmake && \
87+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
88+
echo "source /opt/rh/llvm-toolset-7/enable" >> /etc/bashrc && \
89+
source /etc/bashrc && \
90+
pip install pyinstaller==3.2 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
91+
92+
FROM curve-builder AS curve-1.2.5
93+
LABEL maintainer="Cyber-SiKu <[email protected]>"
94+
# ENV GITHUB_PROXY=https://ghproxy.com/
95+
ENV GITHUB_PROXY=
96+
ARG TARGETARCH
97+
RUN source /etc/bashrc && \
98+
git clone ${GITHUB_PROXY}https://github.com/opencurve/curve --branch v1.2.5 /curve-1.2.5 && \
99+
cd /curve-1.2.5/ && \
100+
# git init && \
101+
if [ "$TARGETARCH" = "arm64" ]; then \
102+
git config --global core.autocrlf input; \
103+
curl https://curve-build.nos-eastchina1.126.net/arm64.patch | git apply; \
104+
sed -i "s;0.17.2;0.17.2-;g" mk-tar.sh; \
105+
else \
106+
sed -i "s;/usr/bin/python2;/opt/rh/python27/root/usr/bin/python2;g" mk-tar.sh; \
107+
fi && \
108+
sed -i "s;tag_version=9.9.9;tag_version=1.2.5;g" mk-tar.sh && \
109+
sed -i "s;commit_id=`git show --abbrev-commit HEAD|head -n 1|awk '{print \$2}'`;commit_id=\"86e8e1a9\";g" mk-tar.sh && \
110+
bash replace-curve-repo.sh && bash mk-tar.sh release && mv curve_1.2.5+86e8e1a9.tar.gz /
111+
112+
FROM centos:7 AS polardb-builder
113+
LABEL maintainer="Cyber-SiKu <[email protected]>"
114+
CMD bash
115+
# avoid missing locale problem
116+
RUN sed -i 's/override_install_langs/# &/' /etc/yum.conf
117+
# add EPEL and scl source
118+
RUN rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \
119+
yum install -y epel-release centos-release-scl && \
120+
rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 && \
121+
rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo && \
122+
yum update -y && \
123+
yum clean all
124+
# GCC and LLVM
125+
RUN yum install -y \
126+
devtoolset-9-gcc \
127+
devtoolset-9-gcc-c++ \
128+
devtoolset-9-gdb \
129+
devtoolset-9-libstdc++-devel \
130+
devtoolset-9-make \
131+
llvm-toolset-7.0-llvm-devel \
132+
llvm-toolset-7.0-clang-devel \
133+
llvm-toolset-7.0-cmake && \
134+
yum clean all
135+
# dependencies
136+
RUN yum install -y \
137+
libicu-devel \
138+
pam-devel \
139+
readline-devel \
140+
libxml2-devel \
141+
libxslt-devel \
142+
openldap-devel \
143+
openldap-clients \
144+
openldap-servers \
145+
libuuid-devel \
146+
xerces-c-devel \
147+
bison \
148+
flex \
149+
gettext \
150+
tcl-devel \
151+
python-devel \
152+
perl-IPC-Run \
153+
perl-Expect \
154+
perl-Test-Simple \
155+
perl-DBD-Pg \
156+
perl-ExtUtils-Embed \
157+
perl-ExtUtils-MakeMaker \
158+
zlib-devel \
159+
krb5-devel \
160+
krb5-workstation \
161+
krb5-server \
162+
protobuf-devel \
163+
libaio-devel \
164+
fuse-devel \
165+
gtest-devel && \
166+
ln /usr/lib64/perl5/CORE/libperl.so /usr/lib64/libperl.so && \
167+
yum clean all
168+
# install basic tools
169+
RUN yum install -y \
170+
git lcov psmisc sudo vim \
171+
less \
172+
net-tools \
173+
python2-psycopg2 \
174+
python2-requests \
175+
tar \
176+
shadow-utils \
177+
which \
178+
binutils\
179+
libtool \
180+
perf \
181+
make sudo \
182+
wget \
183+
util-linux libunwind && \
184+
yum clean all
185+
186+
# copy curve-sdk
187+
COPY --from=curve-1.2.5 /curve_1.2.5+86e8e1a9.tar.gz /
188+
RUN tar -zxvf curve_1.2.5+86e8e1a9.tar.gz && rm curve_1.2.5+86e8e1a9.tar.gz && \
189+
cd /curve/curve-sdk && \
190+
cp -f lib/* /usr/lib64 && \
191+
cp -f bin/* /usr/bin && \
192+
mkdir -p /usr/curvefs && \
193+
cp -f curvefs/* /usr/curvefs && \
194+
cp -f include/* /usr/include && \
195+
rm -rf /curve && \
196+
mkdir -p /etc/curve
197+
COPY --from=curve-1.2.5 /curve-1.2.5/conf/client.conf /etc/curve/client.conf
198+
199+
# set to empty if GitHub is not barriered
200+
# ENV GITHUB_PROXY=https://ghproxy.com/
201+
ENV GITHUB_PROXY=
202+
ENV ZLOG_VERSION=1.2.14
203+
ENV OPENSSL_VERSION=OpenSSL_1_1_1k
204+
ENV PFSD_VERSION=curvebs_sdk_devio
205+
# install dependencies from GitHub mirror
206+
RUN cd /usr/local && \
207+
# zlog for PFSD
208+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/HardySimpson/zlog/archive/refs/tags/${ZLOG_VERSION}.tar.gz" && \
209+
# PFSD
210+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/opencurve/PolarDB-FileSystem/archive/refs/heads/${PFSD_VERSION}.tar.gz" && \
211+
# OpenSSL 1.1.1
212+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/openssl/openssl/archive/refs/tags/${OPENSSL_VERSION}.tar.gz" && \
213+
# enable build tools
214+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
215+
echo "source /opt/rh/llvm-toolset-7.0/enable" >> /etc/bashrc && \
216+
source /etc/bashrc && \
217+
# unzip and install zlog
218+
gzip -d $ZLOG_VERSION.tar.gz && \
219+
tar xpf $ZLOG_VERSION.tar && \
220+
cd zlog-$ZLOG_VERSION && \
221+
make && make install && \
222+
echo '/usr/local/lib' >> /etc/ld.so.conf && ldconfig && \
223+
cd .. && \
224+
rm -rf $ZLOG_VERSION* && \
225+
rm -rf zlog-$ZLOG_VERSION && \
226+
# unzip and install OpenSSL 1.1.1
227+
gzip -d $OPENSSL_VERSION.tar.gz && \
228+
tar xpf $OPENSSL_VERSION.tar && \
229+
cd openssl-$OPENSSL_VERSION && \
230+
./config --prefix=/usr/local/openssl && make -j8 && make install && \
231+
cp /usr/local/openssl/lib/lib* /usr/local/lib/ && \
232+
cp -r /usr/local/openssl/include/openssl /usr/local/include/ && \
233+
cd .. && \
234+
rm -rf $OPENSSL_VERSION* && \
235+
rm -rf openssl-$OPENSSL_VERSION && \
236+
ldconfig && \
237+
# unzip and install PFSD
238+
gzip -d $PFSD_VERSION.tar.gz && \
239+
tar xpf $PFSD_VERSION.tar && \
240+
cd PolarDB-FileSystem-$PFSD_VERSION && \
241+
sed -i 's/-march=native //' CMakeLists.txt && \
242+
./autobuild.sh && ./install.sh && \
243+
cd .. && \
244+
rm -rf $PFSD_VERSION* && \
245+
rm -rf PolarDB-FileSystem-$PFSD_VERSION*
246+
# add software repository of Node.js LTS
247+
# @see https://github.com/nodesource/distributions
248+
# use yarn for documentation development
249+
RUN curl -fsSL https://rpm.nodesource.com/setup_16.x | bash - && \
250+
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
251+
yum install -y yarn && \
252+
yum clean all
253+
# create default user
254+
ENV USER_NAME=postgres
255+
RUN echo "create default user" && \
256+
groupadd -r $USER_NAME && \
257+
useradd -g $USER_NAME $USER_NAME -p '' && \
258+
usermod -aG wheel $USER_NAME
259+
WORKDIR /home/$USER_NAME
260+
# modify conf
261+
RUN echo "modify conf" && \
262+
mkdir -p /var/log/pfs && chown $USER_NAME /var/log/pfs && \
263+
mkdir -p /var/run/pfs && chown $USER_NAME /var/run/pfs && \
264+
mkdir -p /var/run/pfsd && chown $USER_NAME /var/run/pfsd && \
265+
mkdir -p /dev/shm/pfsd && chown $USER_NAME /dev/shm/pfsd && \
266+
mkdir -p /data/log/curve/ && chown $USER_NAME /data/log/curve/ && \
267+
sed -i "s;# __CURVEADM_TEMPLATE__ /curvebs/client/logs __CURVEADM_TEMPLATE__;;g" /etc/curve/client.conf && \
268+
touch /var/run/pfsd/.pfsd && \
269+
chkconfig --add pfsd_env && \
270+
echo "ulimit -c unlimited" >> /home/postgres/.bashrc && \
271+
echo "export PATH=/home/postgres/tmp_basedir_polardb_pg_1100_bld/bin:\$PATH" >> /home/postgres/.bashrc && \
272+
echo "export PGHOST=127.0.0.1" >> /home/postgres/.bashrc && \
273+
echo "alias pg='psql -h /home/postgres/tmp_master_dir_polardb_pg_1100_bld/'" >> /home/postgres/.bashrc && \
274+
rm /etc/localtime && \
275+
cp /usr/share/zoneinfo/UTC /etc/localtime && \
276+
sed -i 's/4096/unlimited/g' /etc/security/limits.d/20-nproc.conf && \
277+
sed -i 's/vim/vi/g' /root/.bashrc
278+
USER $USER_NAME

docker/curve/1.2/centos7/Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
.PHONY: build
1+
.PHONY: curve-builder, polardb-builder
22

3-
build:
4-
docker build --tag opencurvedocker/curve-build:latest-centos7 $(PWD)
3+
curve-builder:
4+
docker build --target curve-builder --tag opencurvedocker/curve-build:latest-centos7 $(PWD)
5+
polardb-builder:
6+
docker build --target polardb-builder --tag opencurvedocker/polardb-build:latest-centos7 $(PWD)

0 commit comments

Comments
 (0)