This commit is contained in:
Mike McFetridge
2026-07-20 09:23:17 -04:00
parent c1315882da
commit 72272e4006
3179 changed files with 562960 additions and 14 deletions
@@ -0,0 +1,135 @@
---
services:
gitlab:
image: docker.io/gitlab/gitlab-ce:latest
container_name: gitlab
shm_size: '256m'
environment:
PUID: 1000
PGID: 1000
volumes:
- /home/miker/docker/gitlab/config:/etc/gitlab
- /home/miker/docker/gitlab/logs:/var/log/gitlab
- /home/miker/docker/gitlab/data:/var/opt/gitlab
ports:
# --> (Optional) Remove when using traefik...
- "8080:80"
- "8443:443"
- '222:22'
restart: unless-stopped
# Lookup password assigned at install
# sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
To use the GitLab runner in GitLab, you need to configure it. For correct configuration, we will need a token copied from the portal. To do this, go to the address: http://localhost:8080/admin/runners and click the Copy token button.
In the next step, it goes to the console and run the following command:
> docker exec -it gitlab-runner gitlab-runner register --url "http://gitlab-ce" --clone-url "http://gitlab-ce"
After launching, a configuration module will appear. The module provides the following information:
Enter the GitLab instance URL: confirm the entered value (click enter)
Enter the registration token: enter the token copied before.
Enter a description for the runner: enter the name of the runner, e.g. docker-runner
Enter tags for the runner: leave the field blank here
Enter an executor: enter docker here
Enter the default Docker image: here we provide the default docker image, e.g. maven: latest
After proper configuration, we should see confirmation Runner registred successfully:
In addition to the basic configuration, we also need to allow access for containers launched from the runner to the virtual network in which GitLab operates. To do this, we run the editor (e.g. vi)
> sudo vi gitlab/gitlab-runner/config.toml
Then we add new line to the end of the runner configuration: network_mode = “gitlab-network”
To check if the runner is available from the GitLab level, go to the following address:http://localhost:8080/admin/runners
We create our first repository
After setting up the runner, we can create our first repository. To do this, go to the page: http://localhost:8080/projects/new and click Import project.
Na następnym ekranie wybieramy Import project from: Repo from URL. Następnie podajemy w Git repository URL adress: https://github.com/czerniga/helloworld.git. Na końcu zatwierdzamy klikając Create project.
On the next screen, select Import project from: Repo from URL. Then we provide the Git repository URL address: https://github.com/czerniga/helloworld.git. Finally, confirm by clicking Create project.
After a while you should have the first repository copied to your GitLab.
We create the CI/CD pipeline
To create a CI/CD pipeline for the project, click the main menu on the left, CI/CD, and then Editor. An option to create a .gitlab-ci.yml file, which will contain our pipeline definitions, will appear on the screen. This file will be created in the Git repository.
On the new screen we can see our pipeline editor. In the editor, paste the following content:
image: maven:latest
stages:
- build
- test
build-job:
stage: build
script:
- echo "Compiling the code..."
- mvn clean package
- echo "Compile complete."
artifacts:
paths:
- target
test-job:
stage: test
dependencies:
- build-job
script:
- ls -al
- echo "Running tests"
- java -cp target/helloworld-1.1.jar com.coveros.demo.helloworld.HelloWorld
The above definition describes how the CI / CD process should work. The most important elements are:
image: docker image that we will use to build our project
stages: a list of our process steps
build-job: the first step in our process to build our project. Additionally, we save the artifacts for use in the next step
test-job: the second step to run our project
After pasting our file, confirm the changes by clicking Commit changes.
Once approved, GitLab will launch the process. To check its results, go to CI/CD -> Pipelines in the menu on the left. On the screen we should see that our first task has already been started.
We can go to the details of this task by clicking on the pending button or the build number #1
After a while, the task should be built and tested.
How to install GitLab using Docker Compose
How to install GitLab using Docker Compose
Congratulations, you have just created your first CI/CD job in GitLab!