Skip to content

Commit 76fb93f

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

File tree

2 files changed

+283
-47
lines changed

2 files changed

+283
-47
lines changed

docker/curve/1.2/centos7/Dockerfile

+278-44
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,282 @@
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
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+
OCI_ARCH=x86_64; \
45+
elif [ "$TARGETARCH" = "arm64" ]; then \
46+
OCI_ARCH=arm64; \
47+
else \
48+
OCI_ARCH=x86_64; \
49+
fi && \
50+
wget https://curve-build.nos-eastchina1.126.net/bazelbuild/bazelisk/bazelisk-linux-${OCI_ARCH} && \
51+
mv bazelisk-linux-${OCI_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-${OCI_ARCH} && \
54+
mkdir -p /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-${OCI_ARCH}/bin && \
55+
mv bazel-4.2.2-linux-${OCI_ARCH} /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-${OCI_ARCH}/bin/bazel && \
56+
wget https://curve-build.nos-eastchina1.126.net/bazelbuild/0.17.2/bazel-0.17.2-linux-${OCI_ARCH} && \
57+
mkdir -p /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-${OCI_ARCH}/bin && \
58+
mv bazel-0.17.2-linux-${OCI_ARCH} /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-${OCI_ARCH}/bin/bazel && \
59+
chmod +x /root/.cache/bazelisk/downloads/bazelbuild/bazel-4.2.2-linux-${OCI_ARCH}/bin/bazel /root/.cache/bazelisk/downloads/bazelbuild/bazel-0.17.2-linux-${OCI_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+
devtoolset-9-gcc \
64+
devtoolset-9-gcc-c++ \
65+
devtoolset-9-libstdc++-devel \
66+
devtoolset-9-make \
67+
llvm-toolset-7.0-cmake \
68+
rh-git227-git \
69+
python2-pip \
70+
python-setuptools \
71+
python2-wheel \
72+
java-1.8.0-openjdk \
73+
java-1.8.0-openjdk-devel && \
74+
echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.aarch64" >> /etc/bashrc && \
75+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
76+
echo "source /opt/rh/llvm-toolset-7.0/enable" >> /etc/bashrc && \
77+
echo "source /opt/rh/rh-git227/enable" >> /etc/bashrc && \
78+
echo "source /opt/rh/httpd24/enable" >> /etc/bashrc; \
79+
else \
80+
yum install -y \
81+
devtoolset-9-gcc \
82+
devtoolset-9-gcc-c++ \
83+
devtoolset-9-libstdc++-devel \
84+
devtoolset-9-make \
85+
llvm-toolset-7-cmake \
86+
sclo-git212 \
87+
python27-python-pip \
88+
python27-python-setuptools \
89+
python27-python-wheel && \
90+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
91+
echo "source /opt/rh/llvm-toolset-7/enable" >> /etc/bashrc && \
92+
echo "source /opt/rh/sclo-git212/enable" >> /etc/bashrc && \
93+
echo "source /opt/rh/python27/enable" >> /etc/bashrc; \
94+
fi && \
95+
source /etc/bashrc && \
96+
pip install pyinstaller==3.2 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
97+
98+
FROM curve-builder AS curve-1.2.5
99+
LABEL maintainer="Cyber-SiKu <[email protected]>"
100+
ENV GITHUB_PROXY=https://ghproxy.com/
101+
# ENV GITHUB_PROXY=
102+
ARG TARGETARCH
103+
RUN source /etc/bashrc && \
104+
git clone ${GITHUB_PROXY}https://github.com/opencurve/curve --branch v1.2.5 /curve-1.2.5 && \
105+
cd /curve-1.2.5/ && \
106+
# git init && \
107+
if [ "$TARGETARCH" = "arm64" ]; then \
108+
git config --global core.autocrlf input; \
109+
curl https://curve-build.nos-eastchina1.126.net/arm64.patch | git apply; \
110+
sed -i "s;0.17.2;0.17.2-;g" mk-tar.sh; \
111+
else \
112+
sed -i "s;/usr/bin/python2;/opt/rh/python27/root/usr/bin/python2;g" mk-tar.sh; \
113+
fi && \
114+
bash replace-curve-repo.sh && \
115+
sed -i "s;tag_version=9.9.9;tag_version=1.2.5;g" mk-tar.sh && \
116+
sed -i "s;commit_id=`git show --abbrev-commit HEAD|head -n 1|awk '{print \$2}'`;commit_id=\"86e8e1a9\";g" mk-tar.sh && \
117+
bash mk-tar.sh release && mv curve_1.2.5+86e8e1a9.tar.gz /
118+
119+
FROM centos:7 AS polardb-builder
120+
LABEL maintainer="Cyber-SiKu <[email protected]>"
121+
CMD bash
122+
# avoid missing locale problem
123+
RUN sed -i 's/override_install_langs/# &/' /etc/yum.conf
124+
# add EPEL and scl source
125+
RUN rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \
126+
yum install -y epel-release centos-release-scl && \
127+
rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 && \
128+
rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo && \
129+
yum update -y && \
130+
yum clean all
131+
# GCC and LLVM
132+
RUN yum install -y \
133+
devtoolset-9-gcc \
134+
devtoolset-9-gcc-c++ \
135+
devtoolset-9-gdb \
136+
devtoolset-9-libstdc++-devel \
137+
devtoolset-9-make \
138+
llvm-toolset-7.0-llvm-devel \
139+
llvm-toolset-7.0-clang-devel \
140+
llvm-toolset-7.0-cmake && \
141+
yum clean all
142+
# dependencies
143+
RUN yum install -y \
144+
libicu-devel \
145+
pam-devel \
146+
readline-devel \
147+
libxml2-devel \
148+
libxslt-devel \
149+
openldap-devel \
150+
openldap-clients \
151+
openldap-servers \
152+
libuuid-devel \
153+
xerces-c-devel \
154+
bison \
155+
flex \
156+
gettext \
157+
tcl-devel \
158+
python-devel \
159+
perl-IPC-Run \
160+
perl-Expect \
161+
perl-Test-Simple \
162+
perl-DBD-Pg \
163+
perl-ExtUtils-Embed \
164+
perl-ExtUtils-MakeMaker \
165+
zlib-devel \
166+
krb5-devel \
167+
krb5-workstation \
168+
krb5-server \
169+
protobuf-devel \
170+
libaio-devel \
171+
fuse-devel \
172+
gtest-devel && \
173+
ln /usr/lib64/perl5/CORE/libperl.so /usr/lib64/libperl.so && \
174+
yum clean all
175+
# install basic tools
176+
RUN yum install -y \
177+
git lcov psmisc sudo vim \
178+
less \
179+
net-tools \
180+
python2-psycopg2 \
181+
python2-requests \
182+
tar \
183+
shadow-utils \
184+
which \
185+
binutils\
186+
libtool \
187+
perf \
188+
make sudo \
189+
wget \
190+
util-linux libunwind && \
191+
yum clean all
192+
193+
# copy curve-sdk
194+
COPY --from=curve-1.2.5 /curve_1.2.5+86e8e1a9.tar.gz /
195+
RUN tar -zxvf curve_1.2.5+86e8e1a9.tar.gz && rm curve_1.2.5+86e8e1a9.tar.gz && \
196+
cd /curve/curve-sdk && \
197+
cp -f lib/* /usr/lib64 && \
198+
cp -f bin/* /usr/bin && \
199+
mkdir -p /usr/curvefs && \
200+
cp -f curvefs/* /usr/curvefs && \
201+
cp -f include/* /usr/include && \
202+
rm -rf /curve && \
203+
mkdir -p /etc/curve
204+
COPY --from=curve-1.2.5 /curve-1.2.5/conf/client.conf /etc/curve/client.conf
15205

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 \
31-
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
206+
# set to empty if GitHub is not barriered
207+
# ENV GITHUB_PROXY=https://ghproxy.com/
208+
ENV GITHUB_PROXY=
209+
ENV ZLOG_VERSION=1.2.14
210+
ENV OPENSSL_VERSION=OpenSSL_1_1_1k
211+
ENV PFSD_VERSION=curvebs_sdk_devio
212+
# install dependencies from GitHub mirror
213+
RUN cd /usr/local && \
214+
# zlog for PFSD
215+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/HardySimpson/zlog/archive/refs/tags/${ZLOG_VERSION}.tar.gz" && \
216+
# PFSD
217+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/opencurve/PolarDB-FileSystem/archive/refs/heads/${PFSD_VERSION}.tar.gz" && \
218+
# OpenSSL 1.1.1
219+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/openssl/openssl/archive/refs/tags/${OPENSSL_VERSION}.tar.gz" && \
220+
# enable build tools
221+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
222+
echo "source /opt/rh/llvm-toolset-7.0/enable" >> /etc/bashrc && \
223+
source /etc/bashrc && \
224+
# unzip and install zlog
225+
gzip -d $ZLOG_VERSION.tar.gz && \
226+
tar xpf $ZLOG_VERSION.tar && \
227+
cd zlog-$ZLOG_VERSION && \
228+
make && make install && \
229+
echo '/usr/local/lib' >> /etc/ld.so.conf && ldconfig && \
230+
cd .. && \
231+
rm -rf $ZLOG_VERSION* && \
232+
rm -rf zlog-$ZLOG_VERSION && \
233+
# unzip and install OpenSSL 1.1.1
234+
gzip -d $OPENSSL_VERSION.tar.gz && \
235+
tar xpf $OPENSSL_VERSION.tar && \
236+
cd openssl-$OPENSSL_VERSION && \
237+
./config --prefix=/usr/local/openssl && make -j8 && make install && \
238+
cp /usr/local/openssl/lib/lib* /usr/local/lib/ && \
239+
cp -r /usr/local/openssl/include/openssl /usr/local/include/ && \
240+
cd .. && \
241+
rm -rf $OPENSSL_VERSION* && \
242+
rm -rf openssl-$OPENSSL_VERSION && \
243+
ldconfig && \
244+
# unzip and install PFSD
245+
gzip -d $PFSD_VERSION.tar.gz && \
246+
tar xpf $PFSD_VERSION.tar && \
247+
cd PolarDB-FileSystem-$PFSD_VERSION && \
248+
sed -i 's/-march=native //' CMakeLists.txt && \
249+
./autobuild.sh && ./install.sh && \
250+
cd .. && \
251+
rm -rf $PFSD_VERSION* && \
252+
rm -rf PolarDB-FileSystem-$PFSD_VERSION*
253+
# add software repository of Node.js LTS
254+
# @see https://github.com/nodesource/distributions
255+
# use yarn for documentation development
256+
RUN curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash - && \
257+
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
258+
yum install -y yarn && \
259+
yum clean all
260+
# create default user
261+
ENV USER_NAME=postgres
262+
RUN echo "create default user" && \
263+
groupadd -r $USER_NAME && \
264+
useradd -g $USER_NAME $USER_NAME -p '' && \
265+
usermod -aG wheel $USER_NAME
266+
WORKDIR /home/$USER_NAME
267+
# modify conf
268+
RUN echo "modify conf" && \
269+
mkdir -p /var/log/pfs && chown $USER_NAME /var/log/pfs && \
270+
mkdir -p /var/run/pfs && chown $USER_NAME /var/run/pfs && \
271+
mkdir -p /var/run/pfsd && chown $USER_NAME /var/run/pfsd && \
272+
mkdir -p /dev/shm/pfsd && chown $USER_NAME /dev/shm/pfsd && \
273+
touch /var/run/pfsd/.pfsd && \
274+
chkconfig --add pfsd_env && \
275+
echo "ulimit -c unlimited" >> /home/postgres/.bashrc && \
276+
echo "export PATH=/home/postgres/tmp_basedir_polardb_pg_1100_bld/bin:\$PATH" >> /home/postgres/.bashrc && \
277+
echo "alias pg='psql -h /home/postgres/tmp_master_dir_polardb_pg_1100_bld/'" >> /home/postgres/.bashrc && \
278+
rm /etc/localtime && \
279+
cp /usr/share/zoneinfo/UTC /etc/localtime && \
280+
sed -i 's/4096/unlimited/g' /etc/security/limits.d/20-nproc.conf && \
281+
sed -i 's/vim/vi/g' /root/.bashrc
282+
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)