Docker deployment

Environmental Preparation

(Defined servers have Docker and Docker-Compose installed by default.)

Create an application deployment directory

# The deployment directory can be adjusted according to actual circumstances.
mkdir /data0/docker

Upload the configuration file.

Upload ChestnutCMS/chestnut-admin/docker/docker-compose_env.yml File to /data0/docker/ Under the directory, make modifications. docker-compose_env.yml File name: ChestnutCMS docker-compose.yml

Modify the configuration

Confirm the following configurations and applications: application-xx.yml The configuration of the content management system for Chestnut Website is consistent with that of ChestnutCMS. Only the environments required, namely MySQL and Redis, need to be configured here. For other components such as Minio, xxl-job, and Elasticsearch, adjust them according to your needs. If there is no need for these components, you can simply remove them from the configuration.

# Database connection password
MYSQL_ROOT_PASSWORD=YOUR_MYSQL_ROOT_PASSWORD
  
# Redis connection password and port number
redis-server --port 6379 --requirepass "YOUR_REDIS_PASSWORD" --appendonly yes

Note: If you need to customize the configuration of MySQL and Redis, please upload the corresponding directories to the /data0/docker/ directory. The directory structure should look like this: ChestnutCMS/chestnut-admin/docker/mysql and redis.

/data0/docker/mysql/conf
  
/data0/docker/redis/conf
  1. Run the following commands to start MySQL and Redis:
cd /data0/docker
docker-compose up -d

Application Deployment

Package the project

The code identifier, version number, numbers, and original meaning should be retained.

cd /path/to/application/ChestnutCMS
mvn -U clean package -Dmaven.test.skip=true

Build Docker images

Taking Alibaba Cloud Image Space as an example (requires Docker environment support)

cd /path/to/application/ChestnutCMS/chestnut-admin
  
# Build images
docker build -t registry.cn-hangzhou.aliyuncs.com/xxxx/chestnut-admin:1.0.0 . --build-arg APP_NAME=chestnut-admin --build-arg APP_VERSION=1.0.0

Push the image to Alibaba Cloud Image Space

# For Docker login, refer to the relevant instructions for the Alibaba Cloud image backend.
docker login --username=${DOCKERUSER} --password-stdin registry.cn-hangzhou.aliyuncs.com 
  
# Upload the image
docker push registry.cn-hangzhou.aliyuncs.com/xxxx/chestnut-admin:1.0.0
  
# Exit Docker
docker logout registry.cn-hangzhou.aliyuncs.com

4. Pulling images from the server

Refer to ChestnutCMS/bin/docker-deploy.sh for more information.

For details on the process, please refer to the Jenkinsfile associated with the project. If you have a Jenkins environment available, you can directly modify the relevant parameters in the Jenkinsfile to perform one-click deployment.

On this page