mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-25 14:08:09 +00:00
launch a postgresql container if we can connect to the host docker
When the database connection parameters are not specified, the image will try to spin up a redis container if it is able to communicate with the host docker. This is only possible if the following two options are specified in the docker run command: `-v /var/run/docker.sock:/run/docker.sock` `-v $(which docker):/bin/docker` This is primarily added to get the quick start guide to work without much of a hassel.
This commit is contained in:
parent
c83bcbfb5f
commit
13f3811e42
39
assets/init
39
assets/init
@ -149,9 +149,38 @@ elif [ -n "${POSTGRESQL_PORT_5432_TCP_ADDR}" ]; then
|
||||
DB_NAME=${DB_NAME:-${POSTGRESQL_ENV_DB}}
|
||||
fi
|
||||
|
||||
# set default user and database
|
||||
DB_USER=${DB_USER:-root}
|
||||
DB_NAME=${DB_NAME:-gitlabhq_production}
|
||||
##
|
||||
## For the sake of getting the quick start guide to work,
|
||||
## we attempt to spin up a postgresql container if possible.
|
||||
##
|
||||
## NOTE: this is only meant for getting the quick start guide to work .
|
||||
##
|
||||
if [ -z "${DB_HOST}" -a -n "$(which docker)" -a -S /var/run/docker.sock ]; then
|
||||
echo "Database connection details not specified."
|
||||
echo "Will try to spin up a new postgresql image with the name postgresql-gitlab."
|
||||
echo "Please manually configure the database connection in production."
|
||||
case "$(docker inspect --format {{.State.Running}} postgresql-gitlab 2>/dev/null)" in
|
||||
true)
|
||||
echo "Using existing postgresql container..."
|
||||
;;
|
||||
false)
|
||||
echo "Starting up existing postgresql container..."
|
||||
docker start postgresql-gitlab >/dev/null 2>/dev/null
|
||||
;;
|
||||
*)
|
||||
echo "Starting up a new postgresql container..."
|
||||
docker run --name='postgresql-gitlab' -d \
|
||||
-e 'DB_USER=gitlab_user' -e 'DB_PASS=gitlab_pass' -e 'DB_NAME=gitlab_db' \
|
||||
sameersbn/postgresql:latest >/dev/null 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
DB_TYPE=postgres
|
||||
DB_HOST=$(docker inspect --format {{.NetworkSettings.IPAddress}} postgresql-gitlab 2>/dev/null)
|
||||
DB_PORT=5432
|
||||
DB_USER=gitlab_user
|
||||
DB_PASS=gitlab_pass
|
||||
DB_NAME=gitlab_db
|
||||
fi
|
||||
|
||||
if [ -z "${DB_HOST}" ]; then
|
||||
echo "ERROR: "
|
||||
@ -173,6 +202,10 @@ case "${DB_TYPE}" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# set default user and database
|
||||
DB_USER=${DB_USER:-root}
|
||||
DB_NAME=${DB_NAME:-gitlabhq_production}
|
||||
|
||||
##
|
||||
## For the sake of getting the quick start guide to work,
|
||||
## we attempt to spin up a redis container if possible.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user