diff --git a/Changelog.md b/Changelog.md index 233df280..bc861165 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/Dockerfile b/Dockerfile index 32e5898d..83a648b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ diff --git a/README.md b/README.md index 25f382ca..64a656f1 100644 --- a/README.md +++ b/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. diff --git a/assets/init b/assets/init index 733a7c4f..5bc3b72c 100755 --- a/assets/init +++ b/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 diff --git a/assets/setup/install b/assets/setup/install index 99b36a66..908a6487 100755 --- a/assets/setup/install +++ b/assets/setup/install @@ -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 < /etc/supervisor/conf.d/cron.conf <