From def992d883b273b58930fdfff5feec290179ef0b Mon Sep 17 00:00:00 2001 From: Ulrich Petri Date: Mon, 6 Jan 2014 11:20:58 +0100 Subject: [PATCH] Added support for external Postgres servers --- Dockerfile | 3 ++- README.md | 44 ++++++++++++++++++++++++++++++++++++----- resources/gitlab | 16 +++++++++++++++ resources/setup/install | 8 ++++---- 4 files changed, 61 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 27968d26..23354f60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,8 @@ RUN apt-get install -y wget curl unzip build-essential checkinstall zlib1g-dev l RUN apt-get install -y python-software-properties && \ add-apt-repository -y ppa:git-core/ppa && \ - apt-get update && apt-get install -y libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev libmysqlclient-dev \ + apt-get update && \ + apt-get install -y libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev libmysqlclient-dev libpq-dev \ sudo nginx git-core mysql-server openssh-server redis-server python2.7 python-docutils postfix logrotate supervisor vim && \ apt-get clean diff --git a/README.md b/README.md index 5c6bbdd3..197ade04 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,36 @@ docker run -d \ sameersbn/gitlab ``` +#### Using an external PostgreSQL server +The image also supports using an external PostgreSQL Server. This is also controlled via environment variables. + +```bash +createuser gitlab +createdb -O gitlab gitlabhq_production +``` + +To make sure the database is initialized start the container with **app:db:initialize** option. + +**NOTE: This should be done only for the first run**. + +*Assuming that the PostgreSQL server host is 192.168.1.100* + +```bash +docker run -d \ + -e "DB_TYPE=postgres" -e "DB_HOST=192.168.1.100" -e "DB_NAME=gitlabhq_production" -e "DB_USER=gitlab" -e "DB_PASS=password" \ + -v /opt/gitlab/data:/home/git/data \ + sameersbn/gitlab app:db:initialize +``` + +This will initialize the gitlab database. Now that the database is initialized, start the container without the initialize command. + +```bash +docker run -d \ + -e "DB_TYPE=postgres" -e "DB_HOST=192.168.1.100" -e "DB_NAME=gitlabhq_production" -e "DB_USER=gitlab" -e "DB_PASS=password" \ + -v /opt/gitlab/data:/home/git/data \ + sameersbn/gitlab +``` + ### Configuring Mail The mail configuration should be specified using environment variables while starting the GitLab image. The configuration defaults to using gmail to send emails and requires the specification of a valid username and password to login to the gmail servers. @@ -294,25 +324,29 @@ Below is the complete list of parameters that can be set using environment varia The number of concurrent sidekiq jobs to run. Defaults to 5 +* DB_TYPE + + The database type. Possible values: mysql, postgres. Defaults to mysql. + * DB_HOST - The mysql server hostname. Defaults to localhost. + The database server hostname. Defaults to localhost. * DB_NAME - The mysql database name. Defaults to gitlabhq_production + The database database name. Defaults to gitlabhq_production * DB_USER - The mysql database user. Defaults to root + The database database user. Defaults to root * DB_PASS - The mysql database password. Defaults to no password + The database database password. Defaults to no password * DB_POOL - The mysql database connection pool count. Defaults to 5. + The database database connection pool count. Defaults to 5. * SMTP_HOST diff --git a/resources/gitlab b/resources/gitlab index c844ebb5..866ca34e 100755 --- a/resources/gitlab +++ b/resources/gitlab @@ -12,6 +12,7 @@ UNICORN_WORKERS=${UNICORN_WORKERS:-2} UNICORN_TIMEOUT=${UNICORN_TIMEOUT:-60} SIDEKIQ_CONCURRENCY=${SIDEKIQ_CONCURRENCY:-5} +DB_TYPE=${DB_TYPE:-mysql} DB_HOST=${DB_HOST:-localhost} DB_NAME=${DB_NAME:-gitlabhq_production} DB_USER=${DB_USER:-root} @@ -29,6 +30,10 @@ SMTP_PASS=${SMTP_PASS:-} # start mysql server if ${DB_HOST} is localhost if [ "${DB_HOST}" == "localhost" ]; then + if [ "${DB_TYPE}" == "postgres" ]; then + echo "DB_TYPE 'postgres' is not supported internally. Please provide DB_HOST." + exit 1 + fi cat > /etc/supervisor/conf.d/mysqld.conf < config/database.yml <