How to Automate Mall‑Swarm Deployment with Jenkins, Docker, and Nacos
This guide walks you through updating the mall‑swarm project to use Nacos for service registration and configuration, preparing Docker images, configuring Jenkins jobs for each microservice, handling Docker network settings, and verifying the deployment, enabling one‑click builds and releases for the entire e‑commerce platform.
Jenkins Basic Usage
Before using this deployment scheme, you need to be familiar with Jenkins. You can refer to the article "Using Jenkins to One‑Click Package and Deploy SpringBoot Applications" for basic Jenkins usage.
Deployment Preparation
Before deployment, install the services required by mall-swarm and build Docker images for all SpringBoot applications. The required components and their versions are:
Mysql 5.7
Redis 5.0
MongoDb 4.3.5
RabbitMq 3.7.15
Nginx 1.10
Elasticsearch 7.6.2
Logstash 7.6.2
Kibana 7.6.2
Nacos 1.3.0
The applications to be packaged and their descriptions are:
mall-monitor – monitoring center
mall-gateway – microservice gateway
mall-auth – authentication center
mall-admin – admin backend service
mall-portal – front‑end portal service
mall-search – search service
All configuration files should be added to the Nacos registry.
Prepare Execution Scripts
Jenkins automation relies on Linux scripts. The scripts are stored in the /document/sh directory of the mall-swarm project. Before uploading, change the line‑ending format to LF in your IDE, then upload the scripts to /mydata/sh on the server and make them executable:
chmod +x ./mall-*Create Jenkins Jobs
We create a freestyle Jenkins job for each module. The process is similar for all modules; the following details the mall-admin job.
mall-admin
Select "Build a free‑style software project", name the job mall-admin, and configure the Git repository (e.g., Gitee address). Add a build step to install dependent modules of mall-swarm:
# only install mall-common and mall-mbg modules
clean install -pl mall-common,mall-mbg -amThen add another build step to package the mall-admin module, and a third step to execute the shell script mall-admin.sh via SSH.
Save the job to complete the mall-admin task creation.
mall-gateway
The mall-gateway job is created by copying the mall-admin job and adjusting the pom.xml path to ${WORKSPACE}/mall-gateway/pom.xml and the script path to /mydata/sh/mall-gateway.sh.
Other modules follow the same pattern.
Docker Network Issues
If you previously used Docker Compose, a default network is created. The custom network used here is deploy_default. Scripts must specify this network, otherwise services cannot reach their dependencies. Use docker inspect mysql or docker network ls to view networks.
# docker network ls
NETWORK ID NAME DRIVER SCOPE
59b309a5c12f bridge bridge local
3a6f76a8920d deploy_default bridge local
ef34fe69992b host host local
a65be030c632 none null localAdd --network deploy_default \ to the shell scripts to ensure services run on the correct network.
Module Startup Order
Although Nacos starts first and other modules have no strict order, the recommended startup sequence is:
mall-auth
mall-gateway
mall-monitor
mall-admin
mall-portal
mall-search
Result Demonstration
After deployment, you can access the following interfaces:
API documentation: http://192.168.3.101:8201/doc.html Nacos console: http://192.168.3.101:8848/nacos/ Monitoring UI: http://192.168.3.101:8101 Kibana (log collection):
http://192.168.3.101:5601Summary
By creating Jenkins tasks, we completed the automated deployment of the mall-swarm project, enabling one‑click packaging and deployment after each code change, thus eliminating repetitive manual steps.
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.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
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.
