Build a Docker‑Based Dev & CI/CD Environment Using Laradock, GitLab, and Jenkins
This guide walks through setting up a complete development and automated deployment stack on a fresh CentOS server, using Docker with Laradock for PHP testing, GitLab for source control, and Jenkins for CI/CD, including detailed command examples, configuration parameters, and plugin setup.
Problem Background
A startup tech team with no existing infrastructure needed to set up code management and automated deployment tools. Over two days they built the essential tools from scratch and share the process here.
Resources
One server with CentOS installed.
Thought : Using traditional yum would lead to a messy environment, so Docker was chosen.
Test Environment Setup
To quickly create a PHP testing environment, Laradock was selected for its comprehensive packaging, allowing flexible service startup later.
Directory structure used:
+ laradock
+ project-1
+ project-2Getting Started
git clone https://github.com/laradock/laradock
cp env-example .envThe .env file can be edited to suit your needs.
docker-compose up -d nginx php-fpm mysql redisYou can append additional services such as rabbitmq or mongo at the end of the command; the first start may take a while.
docker-compose exec --user=laradock workspace bashInside the workspace you can run composer for Laravel projects.
docker-compose exec nginx nginx -s reloadTo reload Nginx after configuration changes, run the above command; the config files are located at ./laradock/nginx/sites/ .
GitLab
After the environment is ready, source code can be stored in GitLab (chosen over GitHub or Gitee). Laradock already provides a GitLab service.
docker \
run -d \
-p 443:443 \
-p 8080:80 \
-p 222:22 \
--name gitlab \
--restart always \
-v /home/gitlab/config:/etc/gitlab \
-v /home/gitlab/logs:/var/log/gitlab \
-v /home/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ceParameter Explanation
-d: Run container in background.
-p: Map host ports to container ports (443→443, 8080→80, 222→22).
-name: Assign a name to the container.
--restart: Restart policy when the container exits.
-v: Volume mount; ensures data persists even if the container fails.
Host /home/gitlab/config is mounted to /etc/gitlab inside the container; adjust paths as needed.
gitlab/gitlab-ce is the image to launch; Docker will pull the latest if missing.
Jenkins
For automated deployment, Jenkins was selected (previous experience). Laradock also provides a Jenkins service.
docker run -d \
--name myjenkins \
-p 8181:8080 \
-p 50000:50000 \
-v /home/jenkins/:/var/jenkins_home \
jenkins/jenkinsParameter Explanation:
-d: Run container in background.
-p: Map host 8181→container 8080 and host 50000→container 50000.
-v: Mount host directory to container to preserve data.
After Jenkins starts, retrieve the initial admin password either by:
# Method 1
docker logs <your_container_name>
# Method 2
cat /home/jenkins/secrets/initialAdminPasswordJenkins Configuration
Initialization
Enter the retrieved password, choose the recommended plugin installation, and later add needed plugins.
Plugin Installation
Install essential plugins:
Publish Over SSH
GitLab Plugin # needed for GitLab integration
NodeJS Plugin # required for Vue front‑end buildsStart the Journey
1. Basic Settings
After installing plugins, configure JDK, Node, SSH, etc.
SSH setup: Manage Jenkins → Configure System → Advanced → Test Configuration.
Configure JDK and Git via Manage Jenkins → Global Tool Configuration (automatic installation is possible).
JDK installation requires a free account.
NodeJS installation (shown in screenshot).
2. Create a Project
New freestyle project.
Create a new job.
Select “Freestyle project”.
3. Configure the Project
Set the number of builds to retain, add Git repository URL and credentials.
Because the SSH step does not support folder transfer, the project is packaged before upload.
if [ -f "test.tar.gz" ];then
rm testv.tar.gz
fi
tar -zcvf test.tar.gz ./*After saving all settings, trigger the build.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
