mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-18 13:58:25 +00:00
removed internal mysql server
This commit is contained in:
parent
4661559669
commit
c83bcbfb5f
@ -1,6 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
**latest**
|
||||
- removed internal mysql server
|
||||
- added support for fetching `DB_NAME`, `DB_USER` and `DB_PASS` from the postgresql linkage
|
||||
- added support for fetching `DB_NAME`, `DB_USER` and `DB_PASS` from the mysql linkage
|
||||
- gitlab-shell: upgrade to v.2.0.1
|
||||
|
||||
@ -3,7 +3,7 @@ MAINTAINER sameer@damagehead.com
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y supervisor logrotate locales \
|
||||
nginx openssh-server mysql-server redis-tools \
|
||||
nginx openssh-server redis-tools \
|
||||
git-core postgresql-client ruby rubygems \
|
||||
python2.7 python-docutils \
|
||||
libmysqlclient18 libpq5 zlib1g libyaml-0-2 libssl1.0.0 \
|
||||
|
||||
39
README.md
39
README.md
@ -202,35 +202,9 @@ GitLab uses a database backend to store its data. You can configure this image t
|
||||
|
||||
#### Internal MySQL Server
|
||||
|
||||
> **Warning**
|
||||
>
|
||||
> The internal mysql server will soon be removed from the image.
|
||||
>
|
||||
> Please use a [linked mysql](#linking-to-mysql-container) container or specify a connection to a [external mysql](#external-mysql-server) server.
|
||||
>
|
||||
> **You've been warned.**
|
||||
>
|
||||
> If you have been using the internal mysql server then first take a backup of the application and then restore the backup after setting up a linked or external mysql server. *NOTE: the backup and restore has to be performed with the same version of the image*
|
||||
>
|
||||
The internal mysql server has been removed from the image. Please use a [linked mysql](#linking-to-mysql-container) container or specify a connection to a [external mysql](#external-mysql-server) server.
|
||||
|
||||
This docker image is configured to use a MySQL database backend. The database connection can be configured using environment variables. If not specified, the image will start a mysql server internally and use it. However in this case, the data stored in the mysql database will be lost if the container is stopped/deleted. To avoid this you should mount a volume at `/var/lib/mysql`.
|
||||
|
||||
SELinux users are also required to change the security context of the mount point so that it plays nicely with selinux.
|
||||
|
||||
```bash
|
||||
mkdir -p /opt/gitlab/mysql
|
||||
sudo chcon -Rt svirt_sandbox_file_t /opt/gitlab/mysql
|
||||
```
|
||||
|
||||
The updated run command looks like this.
|
||||
|
||||
```bash
|
||||
docker run --name=gitlab -d \
|
||||
-v /opt/gitlab/data:/home/git/data \
|
||||
-v /opt/gitlab/mysql:/var/lib/mysql sameersbn/gitlab:7.3.1-3
|
||||
```
|
||||
|
||||
This will make sure that the data stored in the database is not lost when the image is stopped and started again.
|
||||
If you have been using the internal mysql server then first take a backup of the application and then restore the backup after setting up a linked or external mysql server. *NOTE: the backup and restore has to be performed with the same version of the image and should be version `7.3.1-3` or lower*
|
||||
|
||||
#### External MySQL Server
|
||||
|
||||
@ -380,15 +354,6 @@ GitLab uses the redis server for its key-value data store. The redis server conn
|
||||
|
||||
The internal redis server has been removed from the image. Please use a [linked redis](#linking-to-redis-container) container or specify a [external redis](#external-redis-server) connection.
|
||||
|
||||
> **Notice**
|
||||
>
|
||||
> The internal mysql server will also be removed in the next release.
|
||||
>
|
||||
> If you have been using the internal mysql server, then please migrate to a using a [linked mysql server](#linking-to-mysql-container) using the migration instructions listed [here](#internal-mysql-server).
|
||||
>
|
||||
> **You've been warned**
|
||||
>
|
||||
|
||||
### External Redis Server
|
||||
|
||||
The image can be configured to use an external redis server instead of starting a redis server internally. The configuration should be specified using environment variables while starting the GitLab image.
|
||||
|
||||
56
assets/init
56
assets/init
@ -153,15 +153,24 @@ fi
|
||||
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}
|
||||
if [ -z "${DB_HOST}" ]; then
|
||||
echo "ERROR: "
|
||||
echo " Please configure the database connection."
|
||||
echo " Refer http://git.io/wkYhyA for more information."
|
||||
echo " Cannot continue without a database. Aborting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# use default port number if it is still not set
|
||||
case "${DB_TYPE}" in
|
||||
mysql) DB_PORT=${DB_PORT:-3306} ;;
|
||||
postgres) DB_PORT=${DB_PORT:-5432} ;;
|
||||
*) echo "Unsupported database adapter. Available adapters are mysql and postgres." && exit 1 ;;
|
||||
*)
|
||||
echo "ERROR: "
|
||||
echo " Please specify the database type in use via the DB_TYPE configuration option."
|
||||
echo " Accepted values are \"postgres\" or \"mysql\". Aborting..."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
##
|
||||
@ -287,43 +296,6 @@ if [ -f "${SSL_CERTIFICATE_PATH}" -o -f "${CA_CERTIFICATES_PATH}" ]; then
|
||||
update-ca-certificates --fresh >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# fix permissions and ownership of /var/lib/mysql
|
||||
chown -R mysql:mysql /var/lib/mysql
|
||||
chmod 700 /var/lib/mysql
|
||||
|
||||
# initialize MySQL data directory
|
||||
if [ ! -d /var/lib/mysql/mysql ]; then
|
||||
mysql_install_db --user=mysql
|
||||
fi
|
||||
|
||||
echo "Starting mysql server..."
|
||||
supervisorctl start mysqld >/dev/null
|
||||
|
||||
# wait for mysql server to start (max 120 seconds)
|
||||
timeout=120
|
||||
while ! mysqladmin -h ${DB_HOST} -u ${DB_USER} ${DB_PASS:+-p$DB_PASS} status >/dev/null 2>&1
|
||||
do
|
||||
timeout=$(expr $timeout - 1)
|
||||
if [ $timeout -eq 0 ]; then
|
||||
echo "Failed to start mysql server"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if ! mysql -h ${DB_HOST} -u ${DB_USER} ${DB_PASS:+-p$DB_PASS} -e "USE ${DB_NAME};" >/dev/null 2>&1; then
|
||||
mysql -h ${DB_HOST} -u ${DB_USER} ${DB_PASS:+-p$DB_PASS} -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;"
|
||||
mysql -h ${DB_HOST} -u ${DB_USER} ${DB_PASS:+-p$DB_PASS} -e "GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON \`${DB_NAME}\`.* TO 'root'@'localhost';"
|
||||
fi
|
||||
fi
|
||||
|
||||
# configure git for the 'git' user
|
||||
sudo -u git -H git config --global user.name "GitLab"
|
||||
sudo -u git -H git config --global user.email "${GITLAB_EMAIL}"
|
||||
@ -693,8 +665,6 @@ appStop() {
|
||||
supervisorctl stop sshd >/dev/null
|
||||
echo "Stopping nginx..."
|
||||
supervisorctl stop nginx >/dev/null
|
||||
echo "Stopping mysqld..."
|
||||
supervisorctl stop mysqld >/dev/null
|
||||
echo "Stopping supervisord..."
|
||||
kill -15 $(cat /var/run/supervisord.pid)
|
||||
exit
|
||||
|
||||
@ -144,19 +144,6 @@ stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
EOF
|
||||
|
||||
# configure supervisord to start mysql (manual)
|
||||
cat > /etc/supervisor/conf.d/mysqld.conf <<EOF
|
||||
[program:mysqld]
|
||||
priority=20
|
||||
directory=/tmp
|
||||
command=/usr/bin/mysqld_safe
|
||||
user=root
|
||||
autostart=false
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
EOF
|
||||
|
||||
# configure supervisord to start crond
|
||||
cat > /etc/supervisor/conf.d/cron.conf <<EOF
|
||||
[program:cron]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user