Operations 9 min read

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.

Open Source Linux
Open Source Linux
Open Source Linux
Build a Docker‑Based Dev & CI/CD Environment Using Laradock, GitLab, and Jenkins

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-2

Getting Started

git clone https://github.com/laradock/laradock
cp env-example .env
The .env file can be edited to suit your needs.
docker-compose up -d nginx php-fpm mysql redis
You 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 bash
Inside the workspace you can run composer for Laravel projects.
docker-compose exec nginx nginx -s reload
To 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-ce

Parameter 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/jenkins

Parameter 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/initialAdminPassword

Jenkins 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 builds

Start 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerCI/CDAutomationdevopsGitLabJenkinsLaradock
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.