mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-18 13:58:25 +00:00
154 lines
4.5 KiB
Bash
Executable File
154 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# export http_proxy=http://192.168.1.1:3128
|
|
# export ftp_proxy=http://192.168.1.1:3128
|
|
|
|
# add git user
|
|
adduser --disabled-login --gecos 'GitLab' git
|
|
|
|
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
|
|
sudo -u git -H mkdir -p /home/git/gitlab-shell
|
|
wget "https://github.com/gitlabhq/gitlab-shell/archive/v1.8.0.tar.gz" -O - | tar -zvxf - --strip=1 -C /home/git/gitlab-shell/
|
|
chown -R git: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 sed 's/repos_path: "\/home\/git\/repositories"/repos_path: "\/home\/git\/data\/repositories"/' -i config.yml
|
|
sudo -u git -H ./bin/install
|
|
|
|
# install gitlab
|
|
sudo -u git -H mkdir -p /home/git/gitlab
|
|
wget "https://github.com/gitlabhq/gitlabhq/archive/v6.4.3.tar.gz" -O - | tar -zvxf - --strip=1 -C /home/git/gitlab/
|
|
chown -R git:git /home/git/gitlab/
|
|
|
|
cd /home/git/gitlab
|
|
|
|
# copy default configurations
|
|
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/unicorn.rb.example config/unicorn.rb
|
|
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
|
|
|
|
# configure repositories path
|
|
sudo -u git -H sed 's/repos_path: \/home\/git\/repositories\//repos_path: \/home\/git\/data\/repositories\//' -i config/gitlab.yml
|
|
sudo -u git -H sed 's/path: \/home\/git\/gitlab-satellites\//path: \/home\/git\/data\/gitlab-satellites\//' -i config/gitlab.yml
|
|
|
|
# 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 uploads directory
|
|
sudo -u git -H ln -s /home/git/data/uploads public/uploads
|
|
|
|
# create symlink to backups directory
|
|
sudo -u git -H ln -s /home/git/data/backups tmp/backups
|
|
|
|
# create production log
|
|
sudo -u git -H touch log/production.log
|
|
|
|
# install gems required by gitlab
|
|
if [ -d "/gitlab/setup/cache" ]; then
|
|
# offline gem installation
|
|
mv /gitlab/setup/cache vendor/
|
|
chown -R git:git vendor/cache
|
|
sudo -u git -H bundle install --local --deployment --without development test aws
|
|
else
|
|
# online gem installation
|
|
sudo -u git -H bundle install --deployment --without development test aws
|
|
fi
|
|
|
|
# add database.yml template
|
|
sudo -u git -H cat > config/database.yml <<EOF
|
|
production:
|
|
adapter: {{DB_ADAPTER}}
|
|
encoding: {{DB_ENCODING}}
|
|
reconnect: false
|
|
database: {{DB_NAME}}
|
|
host: {{DB_HOST}}
|
|
username: {{DB_USER}}
|
|
password: {{DB_PASS}}
|
|
pool: {{DB_POOL}}
|
|
EOF
|
|
chmod o-rwx config/database.yml
|
|
|
|
sudo -u git -H cat > config/sidekiq.yml <<EOF
|
|
:concurrency: {{SIDEKIQ_CONCURRENCY}}
|
|
EOF
|
|
chmod o-rwx config/sidekiq.yml
|
|
|
|
# make sure everything in /home/git is owned by the git user
|
|
chown -R git:git /home/git/
|
|
|
|
# install gitlab bootscript
|
|
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
|
|
|
|
# install logrotate configuration
|
|
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
|
|
|
|
# copy nginx configuration
|
|
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
|
|
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
|
|
|
|
# create the /var/run/sshd directory (required for sshd to start)
|
|
mkdir -p /var/run/sshd
|
|
|
|
# setup log rotation for supervisord
|
|
cat > /etc/logrotate.d/supervisord <<EOF
|
|
/var/log/supervisor/*.log {
|
|
weekly
|
|
missingok
|
|
rotate 52
|
|
compress
|
|
delaycompress
|
|
notifempty
|
|
copytruncate
|
|
}
|
|
EOF
|
|
|
|
# configure supervisord to start nginx
|
|
sed 's/YOUR_SERVER_FQDN/localhost/' -i /etc/nginx/sites-available/gitlab
|
|
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=true
|
|
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 openssh server
|
|
cat > /etc/supervisor/conf.d/openssh-server.conf <<EOF
|
|
[program:openssh-server]
|
|
priority=20
|
|
directory=/tmp
|
|
command=/usr/sbin/sshd -D
|
|
user=root
|
|
autostart=true
|
|
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 cron
|
|
cat > /etc/supervisor/conf.d/cron.conf <<EOF
|
|
[program:cron]
|
|
priority=20
|
|
directory=/tmp
|
|
command=/usr/sbin/cron -f
|
|
user=root
|
|
autostart=true
|
|
autorestart=true
|
|
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
|
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
|
EOF
|