mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-18 13:58:25 +00:00
148 lines
4.3 KiB
Bash
Executable File
148 lines
4.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
GITLAB_VERSION=7.2.0
|
|
SHELL_VERSION=1.9.7
|
|
|
|
# remove the host keys generated during openssh-server installation
|
|
rm -rf /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub
|
|
|
|
# add git user
|
|
adduser --disabled-login --gecos 'GitLab' git
|
|
passwd -d git
|
|
|
|
rm -rf /home/git/.ssh
|
|
sudo -u git -H mkdir -p /home/git/data/.ssh
|
|
sudo -u git -H ln -s /home/git/data/.ssh /home/git/.ssh
|
|
|
|
# create the data store
|
|
sudo -u git -H mkdir -p /home/git/data
|
|
|
|
# install gitlab-shell, use local copy if available
|
|
sudo -u git -H git clone -b v${SHELL_VERSION} --depth 1 \
|
|
https://github.com/gitlabhq/gitlab-shell.git /home/git/gitlab-shell
|
|
|
|
cd /home/git/gitlab-shell
|
|
|
|
sudo -u git -H cp -a config.yml.example config.yml
|
|
sudo -u git -H ./bin/install
|
|
|
|
# shallow clone gitlab-ce
|
|
sudo -u git -H git clone -b v${GITLAB_VERSION} --depth 1 \
|
|
https://github.com/gitlabhq/gitlabhq.git /home/git/gitlab
|
|
|
|
cd /home/git/gitlab
|
|
|
|
# copy default configurations
|
|
cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
|
|
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
|
|
sudo -u git -H cp config/resque.yml.example config/resque.yml
|
|
sudo -u git -H cp config/database.yml.mysql config/database.yml
|
|
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
|
|
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
|
|
sudo -u git -H cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb
|
|
|
|
# create required tmp and log directories
|
|
sudo -u git -H mkdir -p tmp/pids/ tmp/sockets/
|
|
chmod -R u+rwX log tmp
|
|
|
|
# create symlink to assets in tmp/cache
|
|
rm -rf tmp/cache
|
|
sudo -u git -H ln -s /home/git/data/tmp/cache tmp/cache
|
|
|
|
# create symlink to assets in public/assets
|
|
rm -rf public/assets
|
|
sudo -u git -H ln -s /home/git/data/tmp/public/assets public/assets
|
|
|
|
# create symlink to uploads directory
|
|
rm -rf public/uploads
|
|
sudo -u git -H ln -s /home/git/data/uploads public/uploads
|
|
|
|
# create production log
|
|
sudo -u git -H touch log/production.log
|
|
|
|
# install gems required by gitlab, use local cache if available
|
|
if [ -d "/app/setup/cache" ]; then
|
|
mv /app/setup/cache vendor/
|
|
chown -R git:git vendor/cache
|
|
fi
|
|
sudo -u git -H bundle install --deployment --without development test aws
|
|
|
|
# make sure everything in /home/git is owned by the git user
|
|
chown -R git:git /home/git/
|
|
|
|
# install gitlab bootscript
|
|
cp lib/support/init.d/gitlab /etc/init.d/gitlab
|
|
chmod +x /etc/init.d/gitlab
|
|
|
|
# install logrotate configuration
|
|
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
|
|
|
|
# disable default nginx configuration and enable gitlab's nginx configuration
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
|
|
|
|
# silence setlocale message (#93)
|
|
cat > /etc/default/locale <<EOF
|
|
LC_ALL=en_US.UTF-8
|
|
LANG=en_US.UTF-8
|
|
EOF
|
|
|
|
# disable pam authentication for sshd
|
|
sed 's/UsePAM yes/UsePAM no/' -i /etc/ssh/sshd_config
|
|
sed 's/UsePrivilegeSeparation yes/UsePrivilegeSeparation no/' -i /etc/ssh/sshd_config
|
|
|
|
# configure supervisor to start sshd
|
|
mkdir -p /var/run/sshd
|
|
cat > /etc/supervisor/conf.d/sshd.conf <<EOF
|
|
[program:sshd]
|
|
directory=/
|
|
command=/usr/sbin/sshd -D
|
|
user=root
|
|
autostart=false
|
|
autorestart=true
|
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
|
stderr_logfile=/var/log/supervisor/%(program_name)s_error.log
|
|
EOF
|
|
|
|
# configure supervisord to start nginx
|
|
echo "daemon off;" >> /etc/nginx/nginx.conf
|
|
cat > /etc/supervisor/conf.d/nginx.conf <<EOF
|
|
[program:nginx]
|
|
priority=20
|
|
directory=/tmp
|
|
command=/usr/sbin/nginx
|
|
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 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 redis (manual)
|
|
sed 's/daemonize yes/daemonize no/' -i /etc/redis/redis.conf
|
|
cat > /etc/supervisor/conf.d/redis-server.conf <<EOF
|
|
[program:redis-server]
|
|
priority=20
|
|
directory=/tmp
|
|
command=/usr/bin/redis-server /etc/redis/redis.conf
|
|
user=redis
|
|
autostart=false
|
|
autorestart=true
|
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
|
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
|
EOF
|