diff --git a/README.md b/README.md index c4acaa05..475c6165 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ - [Configuration](#configuration) - [Data Store](#data-store) - [Database](#database) + - [PostgreSQL (Recommended)](#postgresql) + - [External PostgreSQL Server](#external-postgresql-server) + - [Linking to PostgreSQL Container](#linking-to-postgresql-container) - [MySQL](#mysql) - [Internal MySQL Server](#internal-mysql-server) - [External MySQL Server](#external-mysql-server) - [Linking to MySQL Container](#linking-to-mysql-container) - - [PostgreSQL (Recommended)](#postgresql) - - [External PostgreSQL Server](#external-postgresql-server) - - [Linking to PostgreSQL Container](#linking-to-postgresql-container) - [Redis](#redis) - [Internal Redis Server](#internal-redis-server) - [External Redis Server](#external-redis-server) @@ -205,6 +205,81 @@ GitLab uses a database backend to store its data. You can configure this image t *Note: GitLab HQ recommends using PostgreSQL over MySQL* +### PostgreSQL + +#### External PostgreSQL Server + +The image also supports using an external PostgreSQL Server. This is also controlled via environment variables. + +```sql +CREATE ROLE gitlab with LOGIN CREATEDB PASSWORD 'password'; +CREATE DATABASE gitlabhq_production; +GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab; +``` + +We are now ready to start the GitLab application. + +*Assuming that the PostgreSQL server host is 192.168.1.100* + +```bash +docker run --name=gitlab -d \ + --env='DB_TYPE=postgres' --env='DB_HOST=192.168.1.100' \ + --env='DB_NAME=gitlabhq_production' \ + --env='DB_USER=gitlab' --env='DB_PASS=password' \ + --volume=/srv/docker/gitlab/gitlab:/home/git/data \ + sameersbn/gitlab:7.12.2-2 +``` + +#### Linking to PostgreSQL Container + +You can link this image with a postgresql container for the database requirements. The alias of the postgresql server container should be set to **postgresql** while linking with the gitlab image. + +If a postgresql container is linked, only the `DB_TYPE`, `DB_HOST` and `DB_PORT` settings are automatically retrieved using the linkage. You may still need to set other database connection parameters such as the `DB_NAME`, `DB_USER`, `DB_PASS` and so on. + +To illustrate linking with a postgresql container, we will use the [sameersbn/postgresql](https://github.com/sameersbn/docker-postgresql) image. When using postgresql image in production you should mount a volume for the postgresql data store. Please refer the [README](https://github.com/sameersbn/docker-postgresql/blob/master/README.md) of docker-postgresql for details. + +First, lets pull the postgresql image from the docker index. + +```bash +docker pull sameersbn/postgresql:9.4 +``` + +For data persistence lets create a store for the postgresql and start the container. + +SELinux users are also required to change the security context of the mount point so that it plays nicely with selinux. + +```bash +mkdir -p /srv/docker/gitlab/postgresql +sudo chcon -Rt svirt_sandbox_file_t /srv/docker/gitlab/postgresql +``` + +The run command looks like this. + +```bash +docker run --name=postgresql-gitlab -d \ + --env='DB_NAME=gitlabhq_production' \ + --env='DB_USER=gitlab' --env='DB_PASS=password' \ + --volume=/srv/docker/gitlab/postgresql:/var/lib/postgresql \ + sameersbn/postgresql:9.4 +``` + +The above command will create a database named `gitlabhq_production` and also create a user named `gitlab` with the password `password` with access to the `gitlabhq_production` database. + +We are now ready to start the GitLab application. + +```bash +docker run --name=gitlab -d --link=postgresql-gitlab:postgresql \ + --volume=/srv/docker/gitlab/gitlab:/home/git/data \ + sameersbn/gitlab:7.12.2-2 +``` + +Here the image will also automatically fetch the `DB_NAME`, `DB_USER` and `DB_PASS` variables from the postgresql container as they are specified in the `docker run` command for the postgresql container. This is made possible using the magic of docker links and works with the following images: + + - [postgresql](https://registry.hub.docker.com/_/postgresql/) + - [sameersbn/postgresql](https://registry.hub.docker.com/u/sameersbn/postgresql/) + - [orchardup/postgresql](https://registry.hub.docker.com/u/orchardup/postgresql/) + - [paintedfox/postgresql](https://registry.hub.docker.com/u/paintedfox/postgresql/) + ### MySQL #### Internal MySQL Server @@ -301,81 +376,6 @@ Here the image will also automatically fetch the `DB_NAME`, `DB_USER` and `DB_PA - [centurylink/mysql](https://registry.hub.docker.com/u/centurylink/mysql/) - [orchardup/mysql](https://registry.hub.docker.com/u/orchardup/mysql/) -### PostgreSQL - -#### External PostgreSQL Server - -The image also supports using an external PostgreSQL Server. This is also controlled via environment variables. - -```sql -CREATE ROLE gitlab with LOGIN CREATEDB PASSWORD 'password'; -CREATE DATABASE gitlabhq_production; -GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab; -``` - -We are now ready to start the GitLab application. - -*Assuming that the PostgreSQL server host is 192.168.1.100* - -```bash -docker run --name=gitlab -d \ - --env='DB_TYPE=postgres' --env='DB_HOST=192.168.1.100' \ - --env='DB_NAME=gitlabhq_production' \ - --env='DB_USER=gitlab' --env='DB_PASS=password' \ - --volume=/srv/docker/gitlab/gitlab:/home/git/data \ - sameersbn/gitlab:7.12.2-2 -``` - -#### Linking to PostgreSQL Container - -You can link this image with a postgresql container for the database requirements. The alias of the postgresql server container should be set to **postgresql** while linking with the gitlab image. - -If a postgresql container is linked, only the `DB_TYPE`, `DB_HOST` and `DB_PORT` settings are automatically retrieved using the linkage. You may still need to set other database connection parameters such as the `DB_NAME`, `DB_USER`, `DB_PASS` and so on. - -To illustrate linking with a postgresql container, we will use the [sameersbn/postgresql](https://github.com/sameersbn/docker-postgresql) image. When using postgresql image in production you should mount a volume for the postgresql data store. Please refer the [README](https://github.com/sameersbn/docker-postgresql/blob/master/README.md) of docker-postgresql for details. - -First, lets pull the postgresql image from the docker index. - -```bash -docker pull sameersbn/postgresql:9.4 -``` - -For data persistence lets create a store for the postgresql and start the container. - -SELinux users are also required to change the security context of the mount point so that it plays nicely with selinux. - -```bash -mkdir -p /srv/docker/gitlab/postgresql -sudo chcon -Rt svirt_sandbox_file_t /srv/docker/gitlab/postgresql -``` - -The run command looks like this. - -```bash -docker run --name=postgresql-gitlab -d \ - --env='DB_NAME=gitlabhq_production' \ - --env='DB_USER=gitlab' --env='DB_PASS=password' \ - --volume=/srv/docker/gitlab/postgresql:/var/lib/postgresql \ - sameersbn/postgresql:9.4 -``` - -The above command will create a database named `gitlabhq_production` and also create a user named `gitlab` with the password `password` with access to the `gitlabhq_production` database. - -We are now ready to start the GitLab application. - -```bash -docker run --name=gitlab -d --link=postgresql-gitlab:postgresql \ - --volume=/srv/docker/gitlab/gitlab:/home/git/data \ - sameersbn/gitlab:7.12.2-2 -``` - -Here the image will also automatically fetch the `DB_NAME`, `DB_USER` and `DB_PASS` variables from the postgresql container as they are specified in the `docker run` command for the postgresql container. This is made possible using the magic of docker links and works with the following images: - - - [postgresql](https://registry.hub.docker.com/_/postgresql/) - - [sameersbn/postgresql](https://registry.hub.docker.com/u/sameersbn/postgresql/) - - [orchardup/postgresql](https://registry.hub.docker.com/u/orchardup/postgresql/) - - [paintedfox/postgresql](https://registry.hub.docker.com/u/paintedfox/postgresql/) - ## Redis GitLab uses the redis server for its key-value data store. The redis server connection details can be specified using environment variables.