提交 12ac4d43 编写于 作者: L LiFeng

iSulad: add build iSulad via docker container

Signed-off-by: NLiFeng <lifeng68@huawei.com>
上级 50fd0183
cmake_minimum_required (VERSION 3.12.1)
cmake_minimum_required (VERSION 2.8)
project (lcrd)
include(cmake/helper.cmake)
......
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved.
# - lcr licensed under the Mulan PSL v1.
# - You can use this software according to the terms and conditions of the Mulan PSL v1.
# - You may obtain a copy of Mulan PSL v1 at:
# - http://license.coscl.org.cn/MulanPSL
# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# - PURPOSE.
# - See the Mulan PSL v1 for more details.
##- @Description: prepare compile container envrionment
##- @Author: lifeng
##- @Create: 2020-01-10
#######################################################################
# This file describes the isulad compile container image.
#
# Usage:
#
# docker build --build-arg http_proxy=YOUR_HTTP_PROXY_IF_NEEDED \
# --build-arg https_proxy=YOUR_HTTPS_PROXY_IF_NEEDED \
# -t YOUR_IMAGE_NAME -f ./Dockerfile .
FROM centos:7.6.1810
MAINTAINER LiFeng <lifeng68huawei.com>
# Install dependency package
RUN yum clean all && yum swap -y fakesystemd systemd && \
yum install -y epel-release \
yum update -y && \
yum install -y automake \
autoconf \
libtool \
make \
cmake \
which \
gdb \
strace \
rpm-build \
graphviz \
libcap \
libcap-devel \
libxslt \
docbook2X \
libselinux \
libselinux-devel \
libseccomp \
libseccomp-devel \
yajl-devel \
git \
bridge-utils \
dnsmasq \
libcgroup \
rsync \
iptables \
iproute \
net-tools \
unzip \
tar \
wget \
gtest \
gtest-devel \
gmock \
gmock-devel \
cppcheck \
python \
python-pip \
libcurl-devel \
zlib-devel \
glibc-headers \
openssl-devel \
gcc \
gcc-c++ \
hostname \
sqlite-devel \
gpgme \
gpgme-devel \
expect \
systemd-devel \
systemd-libs \
go \
CUnit \
CUnit-devel \
valgrind \
e2fsprogs
RUN pip install xlrd
RUN yum clean all && \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; \
do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> /etc/bashrc && \
echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH" >> /etc/bashrc && \
echo "/usr/lib" >> /etc/ld.so.conf && \
echo "/usr/local/lib" >> /etc/ld.so.conf
# disalbe sslverify
RUN git config --global http.sslverify false
# Centos has no protobuf, protobuf-devel, grpc, grpc-devel, grpc-plugin
# and we should install them manually.
# install protobuf
RUN set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/protobuf.git && \
cd protobuf && \
tar -xzvf protobuf-all-3.9.0.tar.gz && \
cd protobuf-3.9.0 && \
./autogen.sh && \
./configure && \
make -j $(nproc) && \
make install && \
ldconfig
# install c-ares
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/c-ares.git && \
cd c-ares && \
tar -xzvf c-ares-1.15.0.tar.gz && \
cd c-ares-1.15.0 && \
autoreconf -if && \
./configure --enable-shared --disable-dependency-tracking && \
make -j $(nproc) && \
make install && \
ldconfig
# install grpc
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/grpc.git && \
cd grpc && \
tar -xzvf grpc-1.22.0.tar.gz && \
cd grpc-1.22.0 && \
make -j $(nproc) && \
make install && \
ldconfig
# install libevent
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/libevent.git && \
cd libevent && \
tar -xzvf libevent-2.1.11-stable.tar.gz && \
cd libevent-2.1.11-stable && \
./autogen.sh && \
./configure && \
make -j $(nproc) && \
make install && \
ldconfig
# install libevhtp
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/libevhtp.git && \
cd libevhtp && \
tar -xzvf libevhtp-1.2.16.tar.gz && \
cd libevhtp-1.2.16 && \
patch -p1 -F1 -s < ../0001-support-dynamic-threads.patch && \
patch -p1 -F1 -s < ../0002-close-openssl.patch && \
rm -rf build && \
mkdir build && \
cd build && \
cmake -D EVHTP_BUILD_SHARED=on -D EVHTP_DISABLE_SSL=on ../ && \
make -j $(nproc) && \
make install && \
ldconfig
# install http-parser
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/http-parser.git && \
cd http-parser && \
tar -xzvf http-parser-2.9.2.tar.gz && \
cd http-parser-2.9.2 && \
make -j CFLAGS="-Wno-error" && \
make CFLAGS="-Wno-error" install && \
ldconfig
# install libwebsockets
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/libwebsockets.git && \
cd libwebsockets && \
tar -xzvf libwebsockets-2.4.2.tar.gz && \
cd libwebsockets-2.4.2 && \
patch -p1 -F1 -s < ../libwebsockets-fix-coredump.patch && \
mkdir build && \
cd build && \
cmake -DLWS_WITH_SSL=0 -DLWS_MAX_SMP=32 -DCMAKE_BUILD_TYPE=Debug ../ && \
make -j $(nproc) && \
make install && \
ldconfig
# install lxc
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/src-openeuler/lxc.git && \
cd lxc && \
./apply-patches && \
cd lxc-3.0.3 && \
./autogen.sh && \
./configure && \
make -j $(nproc) && \
make install && \
ldconfig
# install lcr
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/openeuler/lcr.git && \
cd lcr && \
mkdir build && \
cd build && \
cmake ../ && \
make -j $(nproc) && \
make install && \
ldconfig
# install clibcni
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/openeuler/clibcni.git && \
cd clibcni && \
mkdir build && \
cd build && \
cmake ../ && \
make -j $(nproc) && \
make install && \
ldconfig
# install iSulad-kit
RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
set -x && \
cd ~ && \
git clone https://gitee.com/openeuler/iSulad-kit.git && \
cd iSulad-kit && \
./apply-patch && \
make -j $(nproc) && \
make install && \
ldconfig
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
......@@ -25,7 +25,7 @@ You can use direct command to start `iSulad` server:
$ sudo lcrd # run the server with default socket name and default log level and images manage function
```
### Operations on containers:
`iSulad` provides command line `lcrd` to talk with server.
`iSulad` provides command line `lcrc` to talk with server.
Here are some sample commands to manager containers.
List all containers in your own environment:
......
## Install Dependencies
# Build iSulad from source
If you intend to contribute on iSulad. Thanks for your effort. Every contribution is very appreciated for us.
## Build iSulad based on openEuler distribution
If you use the openEuler distribution, you can easily install various dependent packages via yum.
### Install Dependencies
```sh
$ sudo yum install -y cmake gcc-c++ systemd-devel yajl-devel libcurl libcurl-devel clibcni clibcni-devel protobuf-devel grpc-devel grpc-plugins http-parser-devel libwebsockets-devel libevhtp-devel libevent-devel lcr lxc-devel
```
## Build steps:
### Build steps:
Run the cmds under the iSulad source directory
```sh
......@@ -17,3 +23,52 @@ $ sudo make
$ sudo make install
```
## Via Docker container
#### Build image
You can build `iSulad` via a Linux-based Docker container. You can build an image from the`Dockerfile` in the source directory. From the iSulad source root directory you can run the following command to make your image.
```sh
$ sudo docker build --build-arg http_proxy=YOUR_HTTP_PROXY_IF_NEED
--build-arg https_proxy=YOUR_HTTPS_PROXY_IF_NEED \
-t YOUR_IMAGE_NAME -f ./Dockerfile .
```
#### Prepare root directory for the iSulad
Let's prepare a root directory on host, and we will mount this directory into the container. This directory be used by `iSulad` in container.
```sh
$ sudo mkdir -p /var/lib/isulad
```
#### Build iSulad in container
Let's suppose that you built an image called `iSulad:dev`.
Then from the iSulad source root directory you can run the following command:
```sh
$ sudo docker run -tid --name YOUR_CONTAINER_NAME -v /var/lib/isulad:/var/lib/lcrd -v `pwd`:/src/isulad --privileged iSulad:dev
```
Let's suppose that you run an container named `iSulad_build`. Then you can use the following commands to build iSulad in your container `iSulad_build`:
```bash
// enter the container
$ sudo docker exec -it iSulad_build bash
// Now you enter the container, so build iSulad in the container by following commands
# cd /src/isulad
# mkdir build
# cd build
# cmake ..
# make
# make install
```
Now You can use direct command to start `iSulad` server in the container:
```sh
$ sudo lcrd # run the server with default socket name and default log level and images manage function
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册