Skip to content

Commit 5b46638

Browse files
authored
Merge pull request #1403 from harsh-ps-2003/testing-instructions-macOS
Modify README.md and add quick test environment setup instructions for macOS
2 parents 99e4acf + 4c16236 commit 5b46638

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

src/docker/README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,58 @@
1-
# Quick test environment setup using Docker
2-
31
In order to test the plugin on different versions of `GitLab` and `Jenkins` you may want to use `Docker` containers.
42

5-
A example docker-compose file is available at `gitlab-plugin/src/docker` which allows to set up instances of the latest `GitLab` and `Jenkins` versions.
3+
# Quick test environment setup using Docker for Linux/amd64
4+
5+
An example docker-compose file is available at `gitlab-plugin/src/docker` which the user can use to set up instances of the latest `GitLab` version and latest `Jenkins` LTS version for linux/amd64.
66

77
If they don't already exist, create the following directories and make sure the user that Docker is running as owns them:
88
* /srv/docker/gitlab/postgresql
99
* /srv/docker/gitlab/gitlab
1010
* /srv/docker/gitlab/redis
1111
* /srv/docker/jenkins
12+
To start the containers for Linux, run `docker-compose up -d` from the `docker` folder. If you have problems accessing the services in the containers, run `docker-compose up` by itself to see output from the services as they start, and the latter command is the verbose version of the former.
13+
14+
## Quick test environment setup using Docker for MacOS/arm64
15+
16+
You need to modify the example docker-compose file available at `gitlab-plugin/src/docker` to set up instances of the latest `GitLab` and `Jenkins` versions for MacOS/arm64.
17+
18+
Due to Apple's System Integrity Protection (SIP), the suggested paths cannot be simply created and accessed, so you may need to use the home directory (~) as a root for the new directories to be created.
1219

13-
To start the containers, run `docker-compose up -d` from the `docker` folder. If you have problems accessing the services in the containers, run `docker-compose up` by itself to see output from the services as they start.
20+
In the `docker-compose.yml` file:
21+
1. Change the ports to
22+
- '55580:80'
23+
- '55522:22'
24+
- '55443:443'
25+
as the browser may block the ports in original docker-compose file.
26+
2. Change the gitlab volumes to
27+
`/Users/yourusername/srv/docker/gitlab/config:/etc/gitlab`
28+
`/Users/yourusername/srv/docker/gitlab/logs:/var/log/gitlab`
29+
`/Users/yourusername/srv/docker/gitlab/data:/var/opt/gitlab`
30+
3. Change the jenkins volumes to
31+
`/Users/yourusername/srv/docker/jenkins:/var/jenkins_home`
32+
4. In your Docker-Desktop go to `Settings > General > Choose file sharing implementation for your containers` and switch to osxfs (Legacy). As `osxfs (Legacy)` utilizes more resources of the system, make sure the assigned resources are sufficient by going to `Settings > Resources` and make suitable adjustments where necessary, otherwise Docker Desktop may go on start mode forever on restarting.
33+
5. Add `shm_size: '5gb'`under gitlab services.
34+
35+
Like the instructions for Linux, for macOS users to start the containers, run `docker-compose up -d` from the `docker` folder. If you have any problems accessing the services in the containers, run `docker-compose up` by itself to see output from the services as they start.
1436

1537
## Access GitLab
1638

17-
To access `GitLab`, point your browser to `http://localhost:10080` and log in with `root` as the username and `password` as the password. Then create a user for Jenkins, impersonate that user, get its API key, set up test repos, etc. When creating webhooks to trigger Jenkins jobs, use `http://jenkins:8080` as the base URL.
39+
To access `GitLab`, you first need to create a user - `root` with some password. To do so, follow the following steps :
40+
1. In the GitLab containers terminal inside Docker Desktop, type `gitlab-rails console` and wait for at least a few minutes for the console to start.
41+
2. Once the console is started successfully, run the following commands in sequence at the console, noting that there are certain security rules to the password choice:
42+
a. `user = User.new(username: 'root', email: '[email protected]', name: 'root', password: 'setyourown', password_confirmation: 'setyourown')`
43+
b. `user.skip_confirmation!`
44+
c. `user.save!`
45+
3. Now, point your browser to `http://localhost:55580` and log in with `root` as the username and `setyourown` as the password. Then create a user for Jenkins, impersonate that user, get its API key, set up test repos, etc. When creating webhooks to trigger Jenkins jobs, use `http://jenkins:8080` as the base URL.
46+
1847

19-
If you have trouble cloning a GitLab repository, it may be because you have a leftover host key from an SSH connection to a previous installation of GitLab in Docker. To troubleshoot, run `ssh -vT git@localhost -p 10022`.
48+
If you have trouble cloning a GitLab repository, it may be because you have a leftover host key from an SSH connection to a previous installation of GitLab in Docker. To troubleshoot, run `ssh -vT git@localhost -p 55522`.
49+
50+
Please note that it is no longer recommended to use ports 10080 and 10022 even for local testing, as more modern browsers have policies set to block the use of such ports.
2051

2152
## Access Jenkins
2253

2354
To see `Jenkins`, point your browser to `http://localhost:8080`. Jenkins will be able to access GitLab at `http://gitlab`.
55+
2456
Note: you need to change the security settings in `Admin -> Settings -> Network -> Outbound Requests -> Allow requests to the local network from hooks and services` in order for local webhooks to work.
2557

2658
For more information on the supported `Jenkins` tags and how to configure the containers, visit https://hub.docker.com/r/jenkins/jenkins/.

src/docker/docker-compose.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@ version: '3'
22

33
services:
44
gitlab:
5-
image: 'gitlab/gitlab-ce:14.7.0-ce.0'
5+
image: 'gitlab/gitlab-ce:latest'
66
restart: "no"
77
hostname: 'localhost'
88
ports:
9-
- '10080:80'
10-
- '10022:22'
9+
- '55580:80'
10+
- '55522:22'
11+
- '55443:443'
1112
volumes:
1213
- '/srv/docker/gitlab/config:/etc/gitlab'
1314
- '/srv/docker/gitlab/logs:/var/log/gitlab'
1415
- '/srv/docker/gitlab/data:/var/opt/gitlab'
1516
environment:
1617
GITLAB_OMNIBUS_CONFIG: |
1718
external_url 'http://localhost'
18-
gitlab_rails['gitlab_shell_ssh_port'] = 10022
19+
gitlab_rails['gitlab_shell_ssh_port'] = 55522
1920
gitlab_rails['initial_root_password'] = 'password'
21+
shm_size: '5gb'
2022

2123
jenkins:
2224
restart: "no"

0 commit comments

Comments
 (0)