From 1d3c7693b762108c5d3fd6f2637482e169073855 Mon Sep 17 00:00:00 2001 From: Lance Ju Date: Wed, 16 Apr 2014 00:16:32 +0800 Subject: [PATCH] Build the database image by the variable DB_TYPE, but not mysql. --- dockerfiles/build.sh.bak | 48 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/dockerfiles/build.sh.bak b/dockerfiles/build.sh.bak index 545a13dae2..1617a1c527 100755 --- a/dockerfiles/build.sh.bak +++ b/dockerfiles/build.sh.bak @@ -1,27 +1,29 @@ -# Configs -MYSQL_PASSWORD="YOUR_MYSQL_PASSWORD" -MYSQL_RUN_NAME="YOUR_MYSQL_RUN_NAME" -typeset -u MYSQL_ALIAS -MYSQL_ALIAS="YOUR_MYSQL_ALIAS" +# Configs of the docker images, you might have specify your own configs here. +# type of database, support 'mysql' and 'postgres' +DB_TYPE="mysql" +DB_PASSWORD="YOUR_DB_PASSWORD" +DB_RUN_NAME="YOUR_DB_RUN_NAME" HOST_PORT="YOUR_HOST_PORT" -# Replace the mysql root password in MySQL image Dockerfile. -sed -i "s/THE_MYSQL_PASSWORD/$MYSQL_PASSWORD/g" images/mysql/Dockerfile -# Replace the mysql root password in gogits image Dockerfile. -sed -i "s/THE_MYSQL_PASSWORD/$MYSQL_PASSWORD/g" images/gogits/Dockerfile +# Replace the database root password in database image Dockerfile. +sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/$DB_TYPE/Dockerfile +# Replace the database root password in gogits image deploy.sh file. +sed -i "s/THE_DB_PASSWORD/$DB_PASSWORD/g" images/gogits/deploy.sh +# Replace the database type in gogits image Dockerfile. +sed -i "s/THE_DB_TYPE/$DB_TYPE/g" images/gogits/Dockerfile - -# Build the MySQL image -cd images/mysql -docker build -i gogs/mysql . - -# Build the gogits image -cd images/gogits -docker build -i gogs/gogits . - -# Run MySQL image with name -docker run -d --name $MYSQL_RUN_NAME gogs/mysql - -# Run gogits image and link it to the MySQL image -docker run --link $MYSQL_RUN_NAME:$MYSQL_ALIAS -p $HOST_PORT:3000 gogs/gogits +# Build the database image +cd images/$DB_TYPE +docker build -t gogs/$DB_TYPE . +# +## Build the gogits image +cd ../gogits +docker build -t gogs/gogits . +# +## Run MySQL image with name +docker run -d --name $DB_RUN_NAME gogs/$DB_TYPE +# +## Run gogits image and link it to the database image +echo "Now we have the $DB_TYPE image(running) and gogs image, use the follow command to start gogs service:" +echo -e "\033[33m docker run -i -t --link $DB_RUN_NAME:db -p $HOST_PORT:3000 gogs/gogits \033[0m"