mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-25 14:08:09 +00:00
init: use linkage to fetch additional mysql access parameters
This commit is contained in:
parent
b7222031df
commit
f504a0fd14
@ -1,6 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
**latest**
|
||||
- added support for fetching `DB_NAME`, `DB_USER` and `DB_PASS` from the mysql linkage
|
||||
- gitlab-shell: upgrade to v.2.0.1
|
||||
- added GITLAB_GRAVATAR_ENABLED configuration option
|
||||
- added fig.yml
|
||||
|
||||
23
README.md
23
README.md
@ -290,39 +290,28 @@ mkdir -p /opt/mysql/data
|
||||
sudo chcon -Rt svirt_sandbox_file_t /opt/mysql/data
|
||||
```
|
||||
|
||||
The updated run command looks like this.
|
||||
The run command looks like this.
|
||||
|
||||
```bash
|
||||
docker run --name=mysql -d \
|
||||
-e 'DB_NAME=gitlabhq_production' -e 'DB_USER=gitlab' -e 'DB_PASS=password' \
|
||||
-v /opt/mysql/data:/var/lib/mysql \
|
||||
sameersbn/mysql:latest
|
||||
```
|
||||
|
||||
You should now have the mysql server running. By default the sameersbn/mysql image does not assign a password for the root user and allows remote connections for the root user from the `172.17.%.%` address space. This means you can login to the mysql server from the host as the root user.
|
||||
|
||||
Now, lets login to the mysql server and create a user and database for the GitLab application.
|
||||
|
||||
```bash
|
||||
docker run -it --rm sameersbn/mysql:latest mysql -uroot -h$(docker inspect --format {{.NetworkSettings.IPAddress}} mysql)
|
||||
```
|
||||
|
||||
```sql
|
||||
CREATE USER 'gitlab'@'172.17.%.%' IDENTIFIED BY 'password';
|
||||
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
|
||||
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'172.17.%.%';
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
The above command will create a database named `gitlabhq_production` and also create a user named `gitlab` with the password `password` with full/remote access to the `gitlabhq_production` database.
|
||||
|
||||
We are now ready to start the GitLab application.
|
||||
|
||||
```bash
|
||||
docker run --name=gitlab -d --link mysql:mysql \
|
||||
-e 'DB_USER=gitlab' -e 'DB_PASS=password' \
|
||||
-e 'DB_NAME=gitlabhq_production' \
|
||||
-v /opt/gitlab/data:/home/git/data \
|
||||
sameersbn/gitlab:7.3.1-3
|
||||
```
|
||||
|
||||
The image will automatically fetch the `DB_NAME`, `DB_USER` and `DB_PASS` variables from the mysql container using the magic of docker links and works with the following images:
|
||||
- [sameersbn/mysql](https://registry.hub.docker.com/u/sameersbn/mysql/)
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
#### External PostgreSQL Server
|
||||
|
||||
14
assets/init
14
assets/init
@ -57,8 +57,8 @@ SIDEKIQ_CONCURRENCY=${SIDEKIQ_CONCURRENCY:-5}
|
||||
DB_TYPE=${DB_TYPE:-}
|
||||
DB_HOST=${DB_HOST:-}
|
||||
DB_PORT=${DB_PORT:-}
|
||||
DB_NAME=${DB_NAME:-gitlabhq_production}
|
||||
DB_USER=${DB_USER:-root}
|
||||
DB_NAME=${DB_NAME:-}
|
||||
DB_USER=${DB_USER:-}
|
||||
DB_PASS=${DB_PASS:-}
|
||||
DB_POOL=${DB_POOL:-10}
|
||||
|
||||
@ -118,13 +118,21 @@ REDIS_PORT=${REDIS_PORT:-6379}
|
||||
if [ -n "${MYSQL_PORT_3306_TCP_ADDR}" ]; then
|
||||
DB_TYPE=${DB_TYPE:-mysql}
|
||||
DB_HOST=${DB_HOST:-${MYSQL_PORT_3306_TCP_ADDR}}
|
||||
DB_PORT=${DB_PORT:-${MYSQL_PORT_3306_TCP_PORT}}
|
||||
|
||||
# support for linked sameersbn/mysql image
|
||||
DB_USER=${DB_USER:-${MYSQL_ENV_DB_USER}}
|
||||
DB_PASS=${DB_PASS:-${MYSQL_ENV_DB_PASS}}
|
||||
DB_NAME=${DB_NAME:-${MYSQL_ENV_DB_NAME}}
|
||||
elif [ -n "${POSTGRESQL_PORT_5432_TCP_ADDR}" ]; then
|
||||
DB_TYPE=${DB_TYPE:-postgres}
|
||||
DB_HOST=${DB_HOST:-${POSTGRESQL_PORT_5432_TCP_ADDR}}
|
||||
DB_PORT=${DB_PORT:-${POSTGRESQL_PORT_5432_TCP_PORT}}
|
||||
fi
|
||||
|
||||
# set default user and database
|
||||
DB_USER=${DB_USER:-root}
|
||||
DB_NAME=${DB_NAME:-gitlabhq_production}
|
||||
|
||||
# fallback to using the internal mysql server
|
||||
DB_TYPE=${DB_TYPE:-mysql}
|
||||
DB_HOST=${DB_HOST:-localhost}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user