IMPORTANT: Your gitlab environment will have access to your host environment via ssh and will try to push changes into this repo. So this repo shouldn't have any collaborators. After cloning this repo CHANGE remote origin on yours which you have access, so your host can push to your remote. Make this repo private because it will keep your credentials.
-
Install OpenSSH server to your host machine
sudo apt install openssh-server
Allow authentication by public key. Uncomment line in your
/etc/ssh/sshd_config
:PubkeyAuthentication yes
Restart your ssh service
sudo service ssh restart
-
Create
.env
file from.env.example
, replace values if necessary.cp .env.example .env
At least you must change
APP_USER
value and set your host username -
Run the container
docker-compose up -d
NOTE:
Replace gitlab-web-1
to your container name, if necessary
-
Generate ssh keys inside the container
docker exec -it --user git gitlab-web-1 ssh-keygen -q -t rsa -N '' -f /var/opt/gitlab/.ssh/id_rsa -C root@gitlab_web
-
Add generated public key to authorized_keys on your host
docker exec -it gitlab-web-1 cat /var/opt/gitlab/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
-
Reconfigure gitlab and restart your container
docker exec -it gitlab-web-1 gitlab-ctl reconfigure docker restart gitlab-web-1
IMPORTANT:
Actual for second and further deployments. Beware of using existing backups at first deployment due to gitlab builds versions conflicts. Just skip this paragraph at first deployment. In further deployments you will find your backups and configs in appropriate folders of this repo: backups
and config
.
To restore from existing backup run the following command:
NOTE:
Replace gitlab-web-1
to your container name, if necessary
CONTAINER=gitlab-web-1 ./restore.sh
File hook hooks/backup.sh
will generate backup file on every event triggered in GitLab. Then it will be sent to VCS of this repository. If you want to do it manually, run the following command:
NOTE:
Replace gitlab-web-1
to your container name, if necessary
docker exec -it --user git gitlab-web-1 /opt/gitlab/embedded/service/gitlab-rails/file_hooks/backup.sh
or validate your file hooks (will execute all file hooks)
docker exec -it gitlab-web-1 gitlab-rake file_hooks:validate