Setting up GitLab within Docker
I'll be honest, I've been putting this off for quite some time & maybe that's been a good thing?
Why would that be a statement to make?
Well, because the complexity is now removed. not 100% but mostly.
What am I on about? Well, setting up a GitLab repository LOCALLY on your own machine / environment so you can do your own offline source control.
Y'know, there are times you just don't want your code being pushed out to GitHub, even if you've made the repo's private & paid money, it still doesn't stop the owners (Micro$oft) from using your content / code to train their Machine Learning* models against your code - that will eventually put you out of a job as id1ots think that auto-generated code from Machine Learning* models is so good it will do that. It won't, however, I don't particularly want to accelerate that level of dumb thinking.
Answer = install GitHub GitLab locally yourself.
https://docs.gitlab.com/install/docker/
$ docker pull gitlab/gitlab-ce
oh, that's it? (don't do -ee as that is not the community edition, but the enterprise edition)
Well, yes & no. Before running off to do that, I checked out a few things and these are the steps.
So, you DO pull down the image from docker with:
$ docker pull gitlab/gitlab-ce
you can then do a check all is good with:
$ docker image ls | grep gitlab-ce
Now, you can go full steam ahead and create a new container, however, if / when the container stops, you lose all your repos as they are not persisted anywhere. Time to create a docker volume first.
$ docker run -p 8001:80 -v /home/dev/tony/gitlab/config:/etc/gitlab -v /home/dev/tony/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce
That will create a container internally listening on port 80 redirected to port 8001 on my local machine, as 8000 is already in use by Portainer. It will take a good 5+ mins for the container to "do it's thing"
Then do the following to get the assigned root password you will need for logging in:
$ docker ps | grep gitlab-ce
copy the <containerID>
$ docker exec -t <ID> cat /etc/gitlab/initial_root_password
This will list the password, base64 hash? at the end of the output.
Now, open up a web-browser and navigate to:
http://localhost:8001/
Now, when asked to login enter:
username: root
password: <as shown above>
You can stay as the root user, or as I did, create a user account. Now, as I've not hooked up an email server, if you create a user account, you then go back and edit it and add a password. Set it as ChangeMe123! - because when you do login as that user for the first time, guess what, yep, you will be asked to change it.
You can create personal repositories for yourself, but you can also create a Group and add other users and then add repositories under that group.
Before getting too carried away, in the UI you will notice mention of setting up SSH keys for authentication & authorisation.
$ ssh-keygen -t ed25519 -C "<comment>"
LOL - guess who forgot to change the <comment> to something useful.
anyway, that creates a private key & a public key. In the admin UI, you want to paste the value from here:
$ cat /home/tony/.ssh/id_ed25519.pub
This then sets up the authentication between your laptop and the repository, so you can make changes.
I created a new Group repository from the Github Template and modified the read.me file within the admin UI. I then chose to clone the repo, add a file & push it back into the repository.
I made a local directory and then did a git clone. If you click the [Code] blue dropdown, top-right, you will see the SSH command. Unfortunately, it gives you the Container hostname, which cannot be resolved, so you'll need to switch to the Docker IP address, that is why you see it as 172.x.x.x below.
138 cd dev
139 ls -l
140 mkdir node-red
141 cd node-red/
142 git clone git@172.17.0.3:node-red1/test1.git
143 ls -l
144 cd test1
145 ls -l
146 cat README.md
147 nano testfile1.txt
148 ls -l
149 git add .
150 git config --global user.email "tony.pigram@gmail.com"
151 git config --global user.name "tony"
152 git commit -m "aded new file"
153 git push
commands 151 & 152 only have to be done the first time, once set they are set.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 304 bytes | 304.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To 172.17.0.3:node-red1/test1.git
ff0e06b..a6ae063 main -> main
anyway, after doing this, I am now able to add new files locally and push them into the Repository - it has ALWAYS baffled me why they say that is doing a "Pull Request", you're not pulling, you are pushing? I'm sure I can go online & find an answer to that - but I don't care that much, but it does seem the wrong way around to me & I guess that's just a "me" problem.
Right, well, let's just say, that was a LOT SIMPLER than it was about 4years ago when I attempted to do this on an offline Red Hat 7 Server instance - yay!
finally, I can do some version control. Now just have to figure out how to connect it to my node-RED instances. I can do it manually, adding flows.json each time and checking it in, but it'd be nice to work out how the new "Projects" feature works.... and then how to get FlowFuse integrated (or do I have to pay for a version before I can do that? UPDATE: it looks like only github.com works for them)
* I refuse to call them AI models, because they are not. when they are, I will refer to them as such, however, by that point I'll probably no longer exist as a physical human being.
oh yeah, LOL, I'm actually / finally on holiday / vacation - yeah, night 1 = setting this up & doing this write up - I know how to relax :-D
Comments
Post a Comment