Sign inSign up

bugwz/ceph-builder

By bugwz

•Updated over 3 years ago

Docker images for building Ceph

Image
1

313

bugwz/ceph-builder repository overview

⁠Description

Docker image for ceph dev.

⁠Environment

⁠System Env

  • CentOS 8 ( 8.5.2111 )
  • Kernel 4.18.0

⁠Python Virtual Env

  • ceph-pacific
    • Python 3.8.16
    • Pip 23.0
  • ceph-ansible-stable-6.0
    • Python 3.8.16
    • Pip 23.0
    • Ansible 2.10.7

⁠Usage

Start docker image:

docker run -it -v "/data/:/home/data/" -p 80:80 bugwz/ceph-dev:latest /bin/bash

⁠Build Ceph

Set git_repo and git_branch_default config:

sed -i 's/^git_repo=.*$/git_repo=https:\/\/github.com\/ceph\/ceph.git/g' /home/script/build.sh
sed -i 's/^git_branch_default=.*$/git_branch_default=pacific/g' /home/script/build.sh

Start build ceph:

cd /home/script/
./build.sh

⁠Package Ceph

Set git_repo and git_branch_default config:

sed -i 's/^git_repo=.*$/git_repo=https:\/\/github.com\/ceph\/ceph.git/g' /home/script/package.sh
sed -i 's/^git_branch_default=.*$/git_branch_default=pacific/g' /home/script/package.sh

Start package ceph:

cd /home/script/
./package.sh

⁠Deploy Ceph

Set ceph-custom.repo config:

⁠Deploy Ceph By Ansible

⁠Extra Sections

▶ Dockerfile

FROM roboxes/centos8:latest
COPY ./files /home
RUN rm -rf /etc/yum.repos.d/CentOS-Linux-BaseOS.repo \
    && rm -rf /etc/yum.repos.d/CentOS-Linux-AppStream.rep \
    && rm -rf /etc/yum.repos.d/CentOS-Linux-Extras.repo \
    && rm -rf /etc/yum.repos.d/CentOS-Linux-Plus.repo \
    && rm -rf /etc/yum.repos.d/CentOS-Linux-PowerTools.repo \
    && cp /home/init/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo \
    && cp /home/init/ceph-pacific.repo /etc/yum.repos.d/ceph-pacific.repo \
    && dnf clean all \
    && dnf makecache
RUN dnf groupinstall -y 'development tools' \
    && dnf install -y epel-release kernel-headers \
    && dnf install -y zlib zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel \
    && dnf install -y python2-devel python36-devel python38-devel python2-jinja2 python3-jinja2 python38-jinja2 \
    && dnf install -y git snappy csnappy csnappy-devel libffi libffi-devel sshpass createrepo \
    && dnf reinstall -y kernel-headers csnappy-devel snappy csnappy-devel rpm-build rpmdevtools \
    && curl https://pyenv.run | bash \
    && rm -rf /root/.bashrc \
    && cp /home/init/bashrc /root/.bashrc \
    && exec "$SHELL"
RUN source /root/.bashrc \
    && mkdir -p /root/.pyenv/cache/ \
    && cp /home/init/Python-3.6.15.tar.xz /root/.pyenv/cache/ \
    && cp /home/init/Python-3.8.16.tar.xz /root/.pyenv/cache/ \
    && pyenv install 3.6.15 \
    && pyenv install 3.8.16 \
    && pyenv global 3.6.15 \
    && python -m pip install pip --upgrade \
    && pyenv global 3.8.16 \
    && python -m pip install pip --upgrade \
    && pyenv virtualenv ceph-pacific \
    && pyenv activate ceph-pacific \
    && pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
    && pip config set install.trusted-host https://pypi.tuna.tsinghua.edu.cn \
    && python -m pip install pip --upgrade \
    && pyenv deactivate \
    && pyenv virtualenv ceph-ansible-stable-6.0 \
    && pyenv activate ceph-ansible-stable-6.0 \
    && pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
    && pip config set install.trusted-host https://pypi.tuna.tsinghua.edu.cn \
    && python -m pip install pip --upgrade \
    && pip install wheel jinja2==3.0.3 \
    && pip install /home/init/Ansible-v2.10.7.tar.gz \
    && pyenv deactivate
RUN rm -rf ~/.ssh/id_rsa \
    && ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
RUN cp /home/init/ceph-custom.repo /home/rpm/ceph-custom.repo \
    && dnf install -y nginx \
    && rm -rf /etc/nginx/nginx.conf \
    && cp /home/init/nginx.conf /etc/nginx/nginx.conf


▶ bashrc

# .bashrc
 
# User specific aliases and functions
 
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
 
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
 
# PYENV
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
 
# PYENV Auto-completions. This should be towards the end of the file.
eval "$(pyenv init -)"


▶ CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
 
[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


▶ ceph-custom.repo

[ceph_stable]
baseurl = http://ipaddress/rpmbuild/RPMS/el8/$basearch
gpgcheck = 0
name = Ceph Stable $basearch repo
priority = 1
 
[ceph_stable_noarch]
baseurl = http://ipaddress/rpmbuild/RPMS/el8/noarch
gpgcheck = 0
name = Ceph Stable noarch repo
priority = 1


▶ ceph-pacific.repo

[ceph]
name=Ceph packages for $basearch
baseurl=https://mirrors.aliyun.com/ceph/rpm-pacific/el8/$basearch
enabled=1
priority=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
 
[ceph-noarch]
name=Ceph noarch packages
baseurl=https://mirrors.aliyun.com/ceph/rpm-pacific/el8/noarch
enabled=1
priority=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
 
[ceph-source]
name=Ceph source packages
baseurl=https://mirrors.aliyun.com/ceph/rpm-pacific/el8/SRPMS
enabled=0
priority=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
 
[ceph-packages]
name=Ceph packages
baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/storage/$basearch/ceph-pacific/
gpgcheck=0
priority=1


▶ nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main    '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
    access_log          /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    include             /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        autoindex    on;
        root         /home/rpm;
        include      /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}


▶ build.sh

#!/bin/bash
 
root_dir=/home/data/
pyenv_name=ceph-pacific
cpu_num=$(< /proc/cpuinfo grep -c "processor")
 
# Custom conf
git_repo=https://github01.birentech.com/suStor/birenStor
git_branch_default=pacific-dev
git_branch=${1:-"$git_branch_default"}
 
# Download ceph
cd $root_dir || exit
#rm -rf ceph
#git clone -b "$git_branch" "$git_repo" ceph || exit
cd ceph || exit
 
# Build ceph
eval "$(pyenv init -)"
pyenv activate "$pyenv_name" || exit
git submodule update --init --recursive || exit
./install-deps.sh || exit
./do_cmake.sh || exit
cd build || exit
make -j "$cpu_num"
pyenv deactivate


▶ package.sh

#!/bin/bash
 
root_dir=/home/data

=/home/rpm/rpmbuild
ceph_rpm_dir=$root_dir/ceph/rpmbuild
pyenv_name=ceph-pacific
 
# Custom conf
git_repo=
git_branch_default=
git_branch=${1:-"$git_branch_default"}
 
# Download ceph
cd $root_dir || exit
rm -rf ceph
git clone -b "$git_branch" "$git_repo" ceph || exit
cd ceph || exit
 
# Package ceph
eval "$(pyenv init -)"
pyenv activate $pyenv_name || exit
git submodule update --init --recursive || exit
./install-deps.sh || exit
./make-dist || exit
mkdir -p $ceph_rpm_dir/SOURCES
cp ceph-*.tar.bz2 $ceph_rpm_dir/SOURCES
rpmbuild -ba --clean --rmsource --rmspec \
         --define="_topdir $ceph_rpm_dir" \
         --define="_rpmdir $ceph_rpm_dir/RPMS" \
         --define="_builddir $ceph_rpm_dir/BUILD" \
         --define="_sourcedir $ceph_rpm_dir/SOURCES" \
         --define="_specdir $ceph_rpm_dir/SPECS" \
         --define="_srcrpmdir $ceph_rpm_dir/SRPMS" \
         --define="_unpackaged_files_terminate_build 0" \
         ceph.spec --without selinux | tee rpm-build.log
pyenv deactivate
 
# Create rpm repo metadata
ln $ceph_rpm_dir $rpm_dir
createrepo $rpm_dir/RPMS/el8/x86_64/
createrepo $rpm_dir/RPMS/el8/noarch/


Tag summary

Content type

Image

Digest

sha256:db8f46e6c…

Size

626.3 MB

Last updated

over 3 years ago

docker pull bugwz/ceph-builder