In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to achieve Docker deployment front-end separation project, the content is very detailed, interested friends can refer to, hope to be helpful to you.
I. Environmental preparation
Server
Ali CVM 1 core + 2GB is fine.
Software
This deployment uses docker, so the software environment is on docker.
We need MySQL 8.0.x version, Redis,Nginx, which can be mirrored in advance.
Second, run the image
MySQL installation
I use the 8.0.x version of MySQL. There are some problems in the deployment process. I would like to share with you here.
Docker run\-p 3306 privileged=true 3306\-name mysql\-- privileged=true\-- restart unless-stopped\-v / home/mysql8.0.20/mysql:/etc/mysql\-v / home/mysql8.0.20/logs:/logs\-v / home/mysql8.0.20/data:/var/lib/mysql\-v / home/mysql8.0.20/mysql-files:/var/lib/mysql-files\-v / etc/localtime:/etc/localtime\-e MYSQL_ROOT _ PASSWORD=123456\-d mysql:8.0.20\-- lower_case_table_names=1
The command explains:
-p port mapping-privileged=true mount file permission settings-restart unless-stopped settings automatically restart the container after boot-v / home/mysql8.0.20/mysql:/etc/mysql mount configuration file-v / home/mysql8.0.20/logs:/logs\ mount log-v / home/mysql8.0.20/data:/var/lib/mysql\ mount data files are persisted to the host After v / home/mysql8.0.20/mysql-files:/var/lib/mysql-files MySQL8, you need to synchronize this folder-v / etc/localtime:/etc/localtime container time synchronizes with the host-e MYSQL_ROOT_PASSWORD=123456 sets password-d mysql:8.0.20 starts in the background Mysql--lower_case_table_names=1 makes MySQL case-insensitive (0: case-sensitive 1: case insensitive)
There is a problem with Table XX.QRTZ_LOCKS doesn't exist before configuring-- lower_case_table_names=1
After some time, Baidu found that the configuration of MySQL 5.x and 8.x is still a little different.
PS:MySQL8.0.2 startup report Different lower_case_table_names settings for server ('1') and data dictionary ('0').
Record that after MySQL 8.0.20 is installed, lower_case_table_names=1 is set in my.cnf during initialization, and the error message is started:
As follows
Check the MySQL official document, there is a record:
Lower_case_table_names can only be configured when initializing the
Server. Changing the lower_case_table_names setting after the server
Is initialized is prohibited.
Setting lower_case_table_names=1 is valid only during initialization, such as:
-initialize-lower-case-table-names=1
See for details
Https://bugs.mysql.com/bug.php?id=90695
Solve the problem
Make a backup, delete the original MySQL container, rerun MySQL, and add-- lower_case_table_names=1 at the end of the command
Because after MySQL 8, this step needs to be set at initialization time
Redis installs docker run-p 6379name redis- 6379-- name redis- v / home/redis/data/:/data-d redis:3.2 redis-server-- appendonly yes
Command interpretation
-v / home/redis/data/:/data mount data directory-- appendonly yes enables redis persistent Nginx installation
Because I need to mount the directory, I ran the following command
Docker run\-d\-p 80:80\-name nginx\-v / home/nginx/conf:/etc/nginx\-v / home/nginx/html:/usr/share/nginx/html\-v / home/nginx/logs:/var/log/nginx\ nginx
After running, it is found that Baidu will always exit automatically. After checking the log information, Baidu has no results. After a search, it is found that the directory to be mounted needs to be created first when nginx starts, otherwise it will exit automatically.
Therefore, we need to create a mount directory before running the command
Third, package the project
Front end
Modify the devServer node mapping port in vue.config.js, which is consistent with the backend port
Run the following command:
Npm run build:prod
The dist directory is generated locally
Back end
Modify application.yml port and file upload path
Modify logback.xml log generation path log.path
Modify MySQL and Redis addresses
Run the following command:
Mvn cleanmvn package
A jar package is generated under ruoyi-admin 's target, which is what we need.
IV. Deployment
Front end
Configure nginx. Here I configure it under / nginx/conf/conf.d/default.conf and find that the configuration does not take effect. Later, just configure it under / nginx/conf/conf.d/nginx.conf. The specific configuration is as follows:
Server {listen 80; server_name localhost; # can use server ip instead of location / {root / usr/share/nginx/html/dist/; index index.html index.htm index login; try_files $uri $uri/ / index.html last } location / prod-api/ {proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:7777/; # Server ip can be used instead of}}
After my deployment is completed, I find that 404 Not Found will appear if it is not refreshed in the root directory. Find the following solution:
Add try_files $uri $uri/ / index.html last when configuring location
Back end
I use the deployment method of Dockerfile + jar packaged as an image
Dockerfile
FROM java:8VOLUME / jiangADD ruoyi-admin.jar app.jarEXPOSE 7777ENTRYPOINT ["java", "- jar", "app.jar"]
Create a folder in the server, put in the Dockerfile and jar packages, and run the following command to generate an image
Docker build-t ruoyi-vue.
Note: there is one last one.
At this point, we just need to run the generated image.
Docker run-d-p 7777 Docker 7777-- so much for name nflj-vue ruoyi-vue on how to implement the front-and back-end separation project for Docker deployment. I hope the above content can be of some help and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.