Skip to content

Commit 7736186

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

File tree

2 files changed

+253
-47
lines changed

2 files changed

+253
-47
lines changed

docker/curve/1.2/centos7/Dockerfile

+248-44
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,252 @@
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=aarch64; \
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+
yum install -y \
61+
devtoolset-9-gcc \
62+
devtoolset-9-gcc-c++ \
63+
devtoolset-9-libstdc++-devel \
64+
devtoolset-9-make \
65+
llvm-toolset-7-cmake \
66+
sclo-git212 \
67+
python27-python-pip \
68+
python27-python-setuptools \
69+
python27-python-wheel && \
70+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
71+
echo "source /opt/rh/llvm-toolset-7/enable" >> /etc/bashrc && \
72+
echo "source /opt/rh/sclo-git212/enable" >> /etc/bashrc && \
73+
echo "source /opt/rh/python27/enable" >> /etc/bashrc && \
74+
source /etc/bashrc && \
75+
pip install pyinstaller==3.6 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
76+
77+
FROM curve-builder AS curve-1.2.5
78+
LABEL maintainer="Cyber-SiKu <[email protected]>"
79+
ADD https://github.com/opencurve/curve/archive/refs/tags/v1.2.5.tar.gz /
80+
RUN source /etc/bashrc && \
81+
tar xvf v1.2.5.tar.gz && rm v1.2.5.tar.gz && \
82+
cd /curve-1.2.5/ && bash replace-curve-repo.sh && \
83+
git init && \
84+
sed -i "s;tag_version=9.9.9;tag_version=1.2.5;g" mk-tar.sh && \
85+
sed -i "s;commit_id=`git show --abbrev-commit HEAD|head -n 1|awk '{print \$2}'`;commit_id=\"86e8e1a\";g" mk-tar.sh && \
86+
sed -i "s;/usr/bin/python2;/opt/rh/python27/root/usr/bin/python2;g" mk-tar.sh && \
87+
bash mk-tar.sh release && mv curve_1.2.5+86e8e1a.tar.gz /
88+
89+
FROM centos:7 AS polardb-builder
90+
LABEL maintainer="Cyber-SiKu <[email protected]>"
91+
CMD bash
92+
# avoid missing locale problem
93+
RUN sed -i 's/override_install_langs/# &/' /etc/yum.conf
94+
# add EPEL and scl source
95+
RUN rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \
96+
yum install -y epel-release centos-release-scl && \
97+
rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 && \
98+
rpmkeys --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo && \
99+
yum update -y && \
100+
yum clean all
101+
# GCC and LLVM
102+
RUN yum install -y \
103+
devtoolset-9-gcc \
104+
devtoolset-9-gcc-c++ \
105+
devtoolset-9-gdb \
106+
devtoolset-9-libstdc++-devel \
107+
devtoolset-9-make \
108+
llvm-toolset-7.0-llvm-devel \
109+
llvm-toolset-7.0-clang-devel \
110+
llvm-toolset-7.0-cmake && \
111+
yum clean all
112+
# dependencies
113+
RUN yum install -y \
114+
libicu-devel \
115+
pam-devel \
116+
readline-devel \
117+
libxml2-devel \
118+
libxslt-devel \
119+
openldap-devel \
120+
openldap-clients \
121+
openldap-servers \
122+
libuuid-devel \
123+
xerces-c-devel \
124+
bison \
125+
flex \
126+
gettext \
127+
tcl-devel \
128+
python-devel \
129+
perl-IPC-Run \
130+
perl-Expect \
131+
perl-Test-Simple \
132+
perl-DBD-Pg \
133+
perl-ExtUtils-Embed \
134+
perl-ExtUtils-MakeMaker \
135+
zlib-devel \
136+
krb5-devel \
137+
krb5-workstation \
138+
krb5-server \
139+
protobuf-devel \
140+
libaio-devel \
141+
fuse-devel \
142+
gtest-devel && \
143+
ln /usr/lib64/perl5/CORE/libperl.so /usr/lib64/libperl.so && \
144+
yum clean all
145+
# install basic tools
146+
RUN yum install -y \
147+
git lcov psmisc sudo vim \
148+
less \
149+
net-tools \
150+
python2-psycopg2 \
151+
python2-requests \
152+
tar \
153+
shadow-utils \
154+
which \
155+
binutils\
156+
libtool \
157+
perf \
158+
make sudo \
159+
wget \
160+
util-linux libunwind && \
161+
yum clean all
162+
163+
# copy curve-sdk
164+
COPY --from=curve-1.2.5 /curve_1.2.5+86e8e1a.tar.gz /
165+
RUN tar -zxvf curve_1.2.5+86e8e1a.tar.gz && rm curve_1.2.5+86e8e1a.tar.gz && \
166+
cd /curve/curve-sdk && \
167+
cp -f lib/* /usr/lib64 && \
168+
cp -f bin/* /usr/bin && \
169+
mkdir -p /usr/curvefs && \
170+
cp -f curvefs/* /usr/curvefs && \
171+
cp -f include/* /usr/include && \
172+
rm -rf /curve && \
173+
mkdir -p /etc/curve
174+
COPY --from=curve-1.2.5 /curve-1.2.5/conf/client.conf /etc/curve/client.conf
15175

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
176+
# set to empty if GitHub is not barriered
177+
# ENV GITHUB_PROXY=https://ghproxy.com/
178+
ENV GITHUB_PROXY=
179+
ENV ZLOG_VERSION=1.2.14
180+
ENV OPENSSL_VERSION=OpenSSL_1_1_1k
181+
ENV PFSD_VERSION=curvebs_sdk_devio
182+
# install dependencies from GitHub mirror
183+
RUN cd /usr/local && \
184+
# zlog for PFSD
185+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/HardySimpson/zlog/archive/refs/tags/${ZLOG_VERSION}.tar.gz" && \
186+
# PFSD
187+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/opencurve/PolarDB-FileSystem/archive/refs/heads/${PFSD_VERSION}.tar.gz" && \
188+
# OpenSSL 1.1.1
189+
wget --no-verbose --no-check-certificate "${GITHUB_PROXY}https://github.com/openssl/openssl/archive/refs/tags/${OPENSSL_VERSION}.tar.gz" && \
190+
# enable build tools
191+
echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc && \
192+
echo "source /opt/rh/llvm-toolset-7.0/enable" >> /etc/bashrc && \
193+
source /etc/bashrc && \
194+
# unzip and install zlog
195+
gzip -d $ZLOG_VERSION.tar.gz && \
196+
tar xpf $ZLOG_VERSION.tar && \
197+
cd zlog-$ZLOG_VERSION && \
198+
make && make install && \
199+
echo '/usr/local/lib' >> /etc/ld.so.conf && ldconfig && \
200+
cd .. && \
201+
rm -rf $ZLOG_VERSION* && \
202+
rm -rf zlog-$ZLOG_VERSION && \
203+
# unzip and install OpenSSL 1.1.1
204+
gzip -d $OPENSSL_VERSION.tar.gz && \
205+
tar xpf $OPENSSL_VERSION.tar && \
206+
cd openssl-$OPENSSL_VERSION && \
207+
./config --prefix=/usr/local/openssl && make -j8 && make install && \
208+
cp /usr/local/openssl/lib/lib* /usr/local/lib/ && \
209+
cp -r /usr/local/openssl/include/openssl /usr/local/include/ && \
210+
cd .. && \
211+
rm -rf $OPENSSL_VERSION* && \
212+
rm -rf openssl-$OPENSSL_VERSION && \
213+
ldconfig && \
214+
# unzip and install PFSD
215+
gzip -d $PFSD_VERSION.tar.gz && \
216+
tar xpf $PFSD_VERSION.tar && \
217+
cd PolarDB-FileSystem-$PFSD_VERSION && \
218+
sed -i 's/-march=native //' CMakeLists.txt && \
219+
./autobuild.sh && ./install.sh && \
220+
cd .. && \
221+
rm -rf $PFSD_VERSION* && \
222+
rm -rf PolarDB-FileSystem-$PFSD_VERSION*
223+
# add software repository of Node.js LTS
224+
# @see https://github.com/nodesource/distributions
225+
# use yarn for documentation development
226+
RUN curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash - && \
227+
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
228+
yum install -y yarn && \
229+
yum clean all
230+
# create default user
231+
ENV USER_NAME=postgres
232+
RUN echo "create default user" && \
233+
groupadd -r $USER_NAME && \
234+
useradd -g $USER_NAME $USER_NAME -p '' && \
235+
usermod -aG wheel $USER_NAME
236+
WORKDIR /home/$USER_NAME
237+
# modify conf
238+
RUN echo "modify conf" && \
239+
mkdir -p /var/log/pfs && chown $USER_NAME /var/log/pfs && \
240+
mkdir -p /var/run/pfs && chown $USER_NAME /var/run/pfs && \
241+
mkdir -p /var/run/pfsd && chown $USER_NAME /var/run/pfsd && \
242+
mkdir -p /dev/shm/pfsd && chown $USER_NAME /dev/shm/pfsd && \
243+
touch /var/run/pfsd/.pfsd && \
244+
chkconfig --add pfsd_env && \
245+
echo "ulimit -c unlimited" >> /home/postgres/.bashrc && \
246+
echo "export PATH=/home/postgres/tmp_basedir_polardb_pg_1100_bld/bin:\$PATH" >> /home/postgres/.bashrc && \
247+
echo "alias pg='psql -h /home/postgres/tmp_master_dir_polardb_pg_1100_bld/'" >> /home/postgres/.bashrc && \
248+
rm /etc/localtime && \
249+
cp /usr/share/zoneinfo/UTC /etc/localtime && \
250+
sed -i 's/4096/unlimited/g' /etc/security/limits.d/20-nproc.conf && \
251+
sed -i 's/vim/vi/g' /root/.bashrc
252+
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)