Skip to content

Commit

Permalink
add cfs-base dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: zhuzhengyi1 <[email protected]>
  • Loading branch information
zhuzhengyi1 committed Jun 18, 2019
1 parent 75e0ace commit 7b240f2
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 37 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ services:
- docker

before_install:
- docker pull chubaofs/cfs-build:1.0
- docker pull chubaofs/centos-ltp:1.0
- docker pull chubaofs/cfs-base:1.0

script:
- docker/run_docker.sh -l
Expand Down
22 changes: 22 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.12

# intall rocksdb
RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list && \
apt-get update && \
apt-get -y install libz-dev libbz2-dev libsnappy-dev && \
apt-get -y -t stretch-backports install librocksdb-dev

ENV LTP_VERSION=20180926
ENV LTP_SOURCE=https://github.com/linux-test-project/ltp/archive/${LTP_VERSION}.tar.gz

# install ltptest
RUN apt-get install -y xz-utils make gcc flex bison automake autoconf
RUN mkdir -p /tmp/ltp /opt/ltp && cd /tmp/ltp \
&& wget ${LTP_SOURCE} && tar xf ${LTP_VERSION}.tar.gz && cd ltp-${LTP_VERSION} \
&& make autotools && ./configure \
&& make -j "$(getconf _NPROCESSORS_ONLN)" all && make install \
&& rm -rf /tmp/ltp

RUN apt-get install -y jq fuse \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
6 changes: 6 additions & 0 deletions docker/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

RootPath=$(cd $(dirname $0) ; pwd)
CfsBase="chubaofs/cfs-base:1.0"

docker build -t ${CfsBase} -f ${RootPath}/Dockerfile ${RootPath}
50 changes: 29 additions & 21 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ networks:

services:
servers:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
depends_on:
- master1
- master2
Expand All @@ -25,7 +25,7 @@ services:
extnetwork:

master1:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "5901"
- "5902"
Expand All @@ -42,7 +42,7 @@ services:
ipv4_address: 192.168.0.11

master2:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "5901"
- "5902"
Expand All @@ -58,7 +58,7 @@ services:
extnetwork:
ipv4_address: 192.168.0.12
master3:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "5901"
- "5902"
Expand All @@ -75,7 +75,7 @@ services:
ipv4_address: 192.168.0.13

metanode1:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "17210"
- "17220"
Expand All @@ -95,7 +95,7 @@ services:
- "master3"

metanode2:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "17210"
- "17220"
Expand All @@ -114,7 +114,7 @@ services:
- "master2"
- "master3"
metanode3:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "17210"
- "17220"
Expand All @@ -134,7 +134,7 @@ services:
- "master3"

datanode1:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "17310"
- "17320"
Expand All @@ -154,7 +154,7 @@ services:
networks:
extnetwork:
datanode2:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "17310"
- "17320"
Expand All @@ -174,7 +174,7 @@ services:
networks:
extnetwork:
datanode3:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "17310"
- "17320"
Expand All @@ -186,16 +186,12 @@ services:
- ./conf/datanode.json:/cfs/conf/datanode.json
- ./script/start_datanode.sh:/cfs/script/start.sh
command: /bin/sh /cfs/script/start.sh
depends_on:
- "metanode1"
- "metanode2"
- "metanode3"
restart: on-failure
networks:
extnetwork:

datanode4:
image: chubaofs/cfs-build:1.0
image: chubaofs/cfs-base:1.0
ports:
- "17310"
- "17320"
Expand All @@ -207,18 +203,13 @@ services:
- ./conf/datanode.json:/cfs/conf/datanode.json
- ./script/start_datanode.sh:/cfs/script/start.sh
command: /bin/sh /cfs/script/start.sh
depends_on:
- "metanode1"
- "metanode2"
- "metanode3"
restart: on-failure
networks:
extnetwork:

client:
image: chubaofs/centos-ltp:1.0
image: chubaofs/cfs-base:1.0
volumes:
- .:/go/src/github.com/chubaofs/cfs
- ./bin:/cfs/bin
- ./conf/client.json:/cfs/conf/client.json
- ./script/run_test.sh:/cfs/script/start.sh
Expand All @@ -234,3 +225,20 @@ services:
command: /bin/bash /cfs/script/start.sh
networks:
extnetwork:

build:
image: chubaofs/cfs-base:1.0
volumes:
- ../:/go/src/github.com/chubaofs/chubaofs
command:
- bash
- "-c"
- >-
set -e;
mkdir -p /go/src/github.com/chubaofs/chubaofs/docker/bin &&
echo -n 'build server ' ;
cd /go/src/github.com/chubaofs/chubaofs/cmd && bash ./build.sh && mv cmd /go/src/github.com/chubaofs/chubaofs/docker/bin/cfs-server && echo "success" || echo "failed" ;
echo -n 'build client ' ;
cd /go/src/github.com/chubaofs/chubaofs/client && bash ./build.sh && mv client /go/src/github.com/chubaofs/chubaofs/docker/bin/cfs-client && echo 'success' || echo "failed" ;
networks:
extnetwork:
12 changes: 3 additions & 9 deletions docker/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

RootPath=$(cd $(dirname $0)/..; pwd)
GOPATH=/go
GoAppName=github.com/chubaofs/chubaofs
GoAppSrcPath=$GOPATH/src/$GoAppName
ServerBuildDockerImage="chubaofs/cfs-build:1.0"
ClientBuildDockerImage="chubaofs/centos-ltp:1.0"
DataNodeNum=4
export DiskPath="./disk"
export DiskPath="$RootPath/docker/disk"

help() {
cat <<EOF
Expand All @@ -32,8 +27,7 @@ clean() {

# test & build
build() {
docker run --rm -v ${RootPath}:/go/src/github.com/chubaofs/chubaofs $ServerBuildDockerImage /bin/bash -c "cd $GoAppSrcPath && make build_server"
docker run --rm -v ${RootPath}:/go/src/github.com/chubaofs/chubaofs $ClientBuildDockerImage /bin/bash -c "cd $GoAppSrcPath && make build_client"
docker-compose -f ${RootPath}/docker/docker-compose.yml run build
}

# start server
Expand All @@ -43,7 +37,7 @@ start_servers() {
}

start_client() {
docker-compose -f ${RootPath}/docker/docker-compose.yml run client bash -c "/cfs/script/start_client.sh && /bin/bash"
docker-compose -f ${RootPath}/docker/docker-compose.yml run client bash -c "/cfs/script/start_client.sh ; /bin/bash"
}

start_ltptest() {
Expand Down
4 changes: 2 additions & 2 deletions docker/script/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ check_status() {

create_vol() {
echo -n "create vol "
res=$(curl -s "http://$LeaderAddr/admin/createVol?name=ltptest&replicas=2&type=extent&randomWrite=true&capacity=30&owner=ltptest")
res=$(curl -s "http://$LeaderAddr/admin/createVol?name=ltptest&capacity=30&owner=ltptest")
code=$(echo "$res" | jq .code)
if [[ $code -ne 0 ]] ; then
echo " failed, exit"
Expand Down Expand Up @@ -149,7 +149,7 @@ run_ltptest() {
getLeaderAddr
check_status "MetaNode"
check_status "DataNode"
create_vol ; sleep 3
create_vol ; sleep 2
create_dp ; sleep 3
start_client ; sleep 2
run_ltptest
6 changes: 3 additions & 3 deletions docker/script/start_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ create_vol() {
return
fi
echo -n "create vol "
res=$(curl -s "http://$LeaderAddr/admin/createVol?name=$VolName&replicas=2&type=extent&randomWrite=true&capacity=30&owner=ltptest")
res=$(curl -s "http://$LeaderAddr/admin/createVol?name=$VolName&capacity=30&owner=ltptest")
code=$(echo "$res" | jq .code)
if [[ $code -ne 0 ]] ; then
echo "failed, exit"
#curl -s "http://$LeaderAddr/admin/getCluster" | jq
curl -s "http://$LeaderAddr/admin/getCluster" | jq
exit 1
fi
echo "ok"
Expand Down Expand Up @@ -111,6 +111,6 @@ start_client() {
getLeaderAddr
check_status "MetaNode"
check_status "DataNode"
create_vol
create_vol
start_client

0 comments on commit 7b240f2

Please sign in to comment.