Skip to content

Instantly share code, notes, and snippets.

@anon5r
Last active November 22, 2017 17:08
Show Gist options
  • Save anon5r/0b0ff083a948a0a445b6397f982f3f0c to your computer and use it in GitHub Desktop.
Save anon5r/0b0ff083a948a0a445b6397f982f3f0c to your computer and use it in GitHub Desktop.
Update script for GitLab omnibus docker
#!/bin/sh
#DOCKER_TAG=latest
SLEEP_SEC=30
DOCKER_TAG=${1:-latest}
GITLAB_PORT_HTTP=50080
GITLAB_PORT_SSL=443
GITLAB_PORT_SSH=22
echo -e "\e[1;37mPulling tag:\e[m \e[33m$DOCKER_TAG\e[m"
sudo docker pull gitlab/gitlab-ce:$DOCKER_TAG
echo -e "\e[33mCreate backup\e[m"
sudo docker exec -it gitlab gitlab-rake gitlab:backup:create
echo -e "Gitlab dorcker: \e[1;31mSTOP\e[m"
sudo docker stop gitlab
echo -e "\e[31mRemove current gitlab\e[m"
sudo docker rm gitlab
echo -e "\e[1;32mRun updated Gitlab docker\e[m"
$HOME/bin/run-gitlab
sudo docker run --detach \
--hostname gitbit.net \
--name gitlab \
--ulimit sigpending=62793 \
--ulimit nproc=131072 \
--ulimit nofile=60000 \
--ulimit core=0 \
--publish 0.0.0.0:$GITLAB_PORT_HTTP:80 \
--publish $GITLAB_PORT_SSL:443 \
--publish $GITLAB_PORT_SSH:22 \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
--volume /srv/gitlab/logs/reconfigure:/var/log/gitlab/reconfigure \
--volume /srv/gitlab/socks:/var/opt/gitlab/gitlab-rails/sockets \
--volume /srv/gitlab/postgres:/var/opt/gitlab/postgresql \
--volume /etc/localtime:/etc/localtime \
gitlab/gitlab-ce:$DOCKER_TAG
echo -e "\e[1;33mSleeping $SLEEP_SEC sec... \e[m"
sleep $SLEEP_SEC
echo -e "\e[1;37mGitlab upgrade:\e[m gitlab-ctl \e[33mupgrade\e[m"
sudo docker exec -it gitlab gitlab-ctl upgrade
echo -e "\e[1;37mGitlab upgrade:\e[m gitlab-ctl \e[33mpg-upgrade\e[m"
sudo docker exec -it gitlab gitlab-ctl pg-upgrade
echo -e "\e[1;37mGitlab registory GC:\e[m gitlab-ctl \e[33mregistry-garbage-collect\e[m"
sudo docker exec -it gitlab gitlab-ctl registry-garbage-collect
echo -e "\e[1;37mGitlab check:\e[m gitlab-rake gitlab:check"
sudo docker exec -it gitlab gitlab-rake gitlab:check RAILS_ENV=production
echo -e "\e[1;37mGitlab restart:\e[m gitlab-ctl \e[33mrestart\e[m"
sudo docker exec -it gitlab gitlab-ctl restart
sleep 10
# Cleanup doker
echo -e "\e[1;37mCleanup docker:\e[m \e[31mRemove unused images\e[m"
sudo docker rmi $(sudo docker images -q -f dangling=true)
# Update permission for sockets
echo -e "\e[1;33mFix permission for rails sockets\e[m"
#sudo chmod o+rX /srv/gitlab/socks
sudo docker exec -it gitlab update-permissions
echo -e "\e[37m chmod o+rwX /var/opt/gitlab/gitlab-rails/sockets\e[m"
sudo docker exec -it gitlab chmod o+rwX /var/opt/gitlab/gitlab-rails/sockets
echo -e "\e[1;37m chmod o+rwX /var/opt/gitlab/redis/redis.socket\e[m"
sudo docker exec -it gitlab chmod o+rwX var/opt/gitlab/redis/redis.socket
echo -e "\e[1;37mGitlab restart:\e[m gitlab-ctl \e[33mrestart\e[m"
sudo docker restart gitlab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment