Skip to content

Commit

Permalink
#8 add management scripts of docker-compose [ci-skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Liang Wang committed Sep 7, 2019
1 parent 5b6b74d commit fa9e413
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
28 changes: 28 additions & 0 deletions admin/docker/flush.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /bin/bash
###########################################
#
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
rootDir=$(cd $baseDir/../..;pwd)
SUDO_CMD=""

# functions

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
which sudo
if [ $? -eq 0 ]; then
SUDO_CMD=sudo
fi

cd $rootDir
echo "[WARN] wait for 10 seconds before clean up all data, be sure of what you are doing ..."
sleep 10
set -x
docker-compose stop

$SUDO_CMD rm -rf var/activemq/data/*
$SUDO_CMD rm -rf var/mysql/data/*
$SUDO_CMD rm -rf var/redis/data/*
15 changes: 15 additions & 0 deletions admin/docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash
###########################################
#
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
rootDir=$(cd $baseDir/../..;pwd)

# functions

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $rootDir
docker-compose up -d
15 changes: 15 additions & 0 deletions admin/docker/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash
###########################################
#
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
rootDir=$(cd $baseDir/../..;pwd)

# functions

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $rootDir
docker-compose down
68 changes: 68 additions & 0 deletions admin/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#! /bin/bash
###########################################
#
###########################################

# constants
baseDir=$(cd `dirname "$0"`;pwd)
rootDir=$(cd $baseDir/..;pwd)
SUDO_CMD=""
# functions

# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
which sudo
if [ $? -eq 0 ]; then
SUDO_CMD=sudo
fi

if [ ! -d $baseDir/../tmp ]; then
mkdir $baseDir/../tmp
fi

cd $baseDir/..
GIT_COMMIT_SHORT=`git rev-parse --short HEAD`
relasedir=$baseDir/../tmp/clause.dist.$GIT_COMMIT_SHORT

cd $baseDir/../tmp
rm -rf $relasedir; mkdir $relasedir

# copy config file
cp $rootDir/sample.env $relasedir/.env
cp $rootDir/docker-compose.yml $relasedir
cp $rootDir/LICENSE $relasedir
cp $rootDir/README.md $relasedir

# copy database persistence folders
mkdir $relasedir/var
cp -rf $rootDir/var/activemq $relasedir/var
$SUDO_CMD rm -rf $relasedir/var/activemq/data/*

cp -rf $rootDir/var/redis $relasedir/var
$SUDO_CMD rm -rf $relasedir/var/redis/data/*

cp -rf $rootDir/var/mysql $relasedir/var
$SUDO_CMD rm -rf $relasedir/var/mysql/data/*

# copy clause data folder
mkdir $relasedir/var/local
cp -rf $rootDir/var/local/data $relasedir/var/local/data
mkdir -p $relasedir/var/local/workarea

# copy clause mysql database init script
mkdir -p $relasedir/src/clause/config
cp -rf $rootDir/src/clause/config/sql $relasedir/src/clause/config

# copy admin scripts
mkdir $relasedir/admin
cp -rf $rootDir/admin/docker $relasedir/admin

# init git
cp -rf $rootDir/.gitignore $relasedir
cd $relasedir
git init
git add --all
git commit -m "init"
cd ..

tar czf clause.dist.$GIT_COMMIT_SHORT.tgz clause.dist.$GIT_COMMIT_SHORT

0 comments on commit fa9e413

Please sign in to comment.