Skip to content

Commit

Permalink
完善Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
lifei6671 committed Feb 3, 2018
1 parent 0a29049 commit e69ea03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ RUN go get -d ./... && \
CGO_ENABLE=1 go build -v -o mindoc_linux_amd64 -ldflags="-w -X main.VERSION=$TAG -X 'main.BUILD_TIME=`date`' -X 'main.GO_VERSION=`go version`'" && \
rm -rf commands controllers models modules routers tasks vendor docs search data utils graphics .git Godeps uploads/* .gitignore .travis.yml Dockerfile gide.yaml LICENSE main.go README.md conf/enumerate.go conf/mail.go install.lock

WORKDIR /go/src/github.com/lifei6671/mindoc

CMD ["./start.sh"]
22 changes: 15 additions & 7 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ set -e

cd /go/src/github.com/lifei6671/mindoc/

if [ ! -f "conf/app.conf" ] ; then
cp conf/app.conf.example conf/app.conf
if [ ! -f "/go/src/github.com/lifei6671/mindoc/conf/app.conf" ] ; then
cp /go/src/github.com/lifei6671/mindoc/conf/app.conf.example /go/src/github.com/lifei6671/mindoc/conf/app.conf
sed -i "s#^db_adapter=.*#db_adapter=sqlite3#g" conf/app.conf
sed -i "s#^db_database.*#db_database=./database/mindoc.db#g" conf/app.conf
fi

if [ ! -z $DB_ADAPTER ]; then
sed -i "s#^db_adapter=.*#db_adapter=${DB_ADAPTER}#g" conf/app.conf
fi

if [ ! -z $MYSQL_PORT_3306_TCP_ADDR ] ; then
Expand All @@ -16,7 +22,7 @@ if [ ! -z $MYSQL_PORT_3306_TCP_PORT ] ; then
fi

if [ ! -z $MYSQL_INSTANCE_NAME ] ; then
sed -i 's/^db_database.*/db_database='$MYSQL_INSTANCE_NAME'/g' conf/app.conf
sed -i "s#^db_database.*#db_database=${MYSQL_INSTANCE_NAME}#g" conf/app.conf
fi

if [ ! -z $MYSQL_USERNAME ] ; then
Expand All @@ -28,15 +34,18 @@ if [ ! -z $MYSQL_PASSWORD ] ; then
fi

if [ ! -z $HTTP_PORT ] ; then
sed -i "s/^httpport.*/httpport=${HTTP_PORT}/g" conf/app.conf
sed -i 's/^httpport.*/httpport='$HTTP_PORT'/g' conf/app.conf
fi

if [ ! -z $CDNJS ]; then
sed -i "s#^cdnjs.*#cdnjs=$CDNJS#g" conf/app.conf
sed -i "s#^cdnjs=.*#cdnjs=$CDNJS#g" conf/app.conf
fi
if [ ! -z $CDNIMG ]; then
sed -i "s#^cdnimg=.*#cdnimg=$CDNIMG#g" conf/app.conf
fi

if [ ! -z $CDNCSS ]; then
sed -i "s#^cdncss.*#cdncss=$CDNCSS#g" conf/app.conf
sed -i "s#^cdncss=.*#cdncss=$CDNCSS#g" conf/app.conf
fi

if [ ! -z $CDN ]; then
Expand All @@ -46,5 +55,4 @@ fi
sed -i 's/^runmode.*/runmode=prod/g' conf/app.conf

/go/src/github.com/lifei6671/mindoc/mindoc_linux_amd64 install

/go/src/github.com/lifei6671/mindoc/mindoc_linux_amd64

0 comments on commit e69ea03

Please sign in to comment.