📍 Description
The goal on this tutorial to make the small labs that the Jenkins, and Gitlab can run on the VPS and also we can access them with custom subdomain like:
- jenkins.domain.com
- gitlab.domain.com
To make this possible, we need help Nginx Proxy Manager to create proxy to our specific IP Address and port. We will install the jenkins, and gitlab on the docker to make the installation easy.
📍 Getting Started
To get started, we need follow this step by step:
- Install Docker
- Install Nginx Proxy Manager on Docker
- Install Jenkins & Gitlab on Docker
- Add the DNS Manager and set A record subdomain to VPS IP
At this post, I using the Ubuntu 22, the installation it's depend on the server you using, but on the main line, it's the same.
🔥 Install the docker & docker-compose
First, we install docker with this command:
apt install docker
And, we install docker-compose
apt install docker-compose
The docker needed to further action like install the Nginx Proxy Manager, Jenkins and Gitlab. So, make sure you install the docker before do another thing.
🔥 Install Nginx Proxy Manager on Docker
Docker, check! Next, we install the Nginx Proxy Manager on Docker by using this step by step.
- Create a new directory and add docker-compose.yml file similar to this on your new directory:
version: '3'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
- Bring up your stack by running
docker-compose up -d
- Log in to the Admin UI using this default password:
http://your-vps-ip:81
Email: admin@example.com
Password: changeme
All this step by step is same on the original nginx proxy manager documentation:
https://nginxproxymanager.com/guide/#quick-setup
🔥 Install Jenkins
Okay, nginx proxy manager is already installed, next we need install jenkins on docker.
You can run this command to install the jenkins on your vps:
docker run -d --name jenkins -p 9091:8080 -p 50000:50000 jenkins/jenkins:lts-jdk11
After that, your Jenkins will be run on port 8080, you can grep the initial password on the docker logs.
Navigate to http://your-vps-ip:9091 and setup the Jenkins with the initial password.
🔥 Install Gitlab
We successfully install the jenkins and looks like jenkins work perfectly fine, next we need to install gitlab on docker!
- Run this command for initial before install gitlab
mkdir -p gitlab; cd gitlab/
mkdir -p /srv/gitlab/{config/ssl,logs,data}
- Define the environment variable "GITLAB_HOME" with the value as GitLab data directory "/srv/gitlab" as below.
GITLAB_HOME=/srv/gitlab
- Go to gitlab directory and add docker-compose.yml file similar to this on gitlab directory, edit the domain and hostname:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab.yourdomain.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
# Add any other gitlab.rb configuration here, each on its own line
external_url 'http://gitlab.yourdomain.com'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8081:80'
- '4443:443'
- '2224:22'
volumes:
- '${GITLAB_HOME}/config:/etc/gitlab'
- '${GITLAB_HOME}/logs:/var/log/gitlab'
- '${GITLAB_HOME}/data:/var/opt/gitlab'
- '${GITLAB_HOME}/config/ssl:/etc/gitlab/ssl'
- Run the installation
docker-compose up -d
- Get the gitlab initial root password by using this command
sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
📍 Add the DNS Manager and set A record subdomain to VPS IP
All the application is already installed. Yey! Next, we need to pointing our custom subdomain to our VPS / Nginx Proxy Manager, and we will manage the subdomain on our Nginx Proxy Manager.
- Go to your domain DNS Management, and add the subdomain jenkins, gitlab and pointing to your vps (that we install nginx proxy manager, jenkins, gitlab) like screenshot below.
- Go to Nginx Proxy Manager, add the subdomain that we already setup earlier and add the your vps IP and Port.
Example: We setup the jenkins on port 9091, so we input the your-vps-ip:9091 on the Forward Hostname / IP
sections, as shown on the screenshot below.
- Add the SSL
Go to SSL tab on the right side and set the SSL as shown on the screenshot below.
And saved the changes.
- Go to your subdomain!
After that, you just need to navigate to your jenkins subdomain, and you will see the jenkins webservice on your subdomain.
Great! Mission Success! Now, you can add the gitlab and proxy manager custom subdomain too!
🔥 References:
https://forum.gitlab.com/t/how-to-login-for-the-first-time-local-install-with-docker-image/55297
https://www.howtoforge.com/how-to-install-gitlab-with-docker-on-ubuntu-2004/
https://octopus.com/blog/jenkins-docker-install-guide
https://nginxproxymanager.com/guide/#quick-setup
https://aksarakode.com/
Top comments (2)
Nice first post. You might want to add #gitlab as a tag
Sorry, missclick to publish the article when the article on halfway. Thanks for the suggestion, I already add #gitlab as well.