Skip to content

Commit f8ecad3

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

File tree

2 files changed

+282
-47
lines changed

2 files changed

+282
-47
lines changed

docker/curve/1.2/centos7/Dockerfile

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