赞
踩
目录
4.在/root/ruoyi/java下写一个Dockerfile用于后端Java环境
7.在/root/ruoyi目录下写docker-compose.yml文件
mkdir /root/ruoyi
cd /root/ruoyi
git clone https://gitee.com/y_project/RuoYi-Vue.git
①修改ruoyi的配置文件
vim /root/ruoyi/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml +9
如下图:
vim /root/ruoyi/RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml +71
如下图:
docker pull node:12
①进入到RuoYi-Vue目录
cd /root/ruoyi/RuoYi-Vue
②启动node镜像
docker run -itd --rm -v ./ruoyi-ui:/opt node:12 /bin/bash
③进入到/opt下(我选择映射在/opt)
root@10cb919b400e:/# cd /opt
③打包前端代码
root@10cb919b400e:/opt# npm install
成功如下图:
root@10cb919b400e:/opt# npm run build:prod
成功如下图:
在/root/ruoyi/RuoYi-Vue/ruoyi-ui目录下会生成一个dist目录
docker pull maven:3.6.3-openjdk-11
① 启动maven镜像
[root@localhost ~]# docker run -it --rm -v ./RuoYi-Vue:/vue maven:3.6.3-openjdk-11 /bin/bash
②进入到/vue
root@61d9e34ad172:/# cd /vue/
③打包后端项目
root@61d9e34ad172:/vue# mvn package
成功如下图:
④退出maven容器,将/root/ruoyi/RuoYi-Vue/ruoyi-admin/target/ ruoyi-admin.jar移到/ruoyi下
[root@localhost target]# mv ruoyi-admin.jar /root/ruoyi
①mkdir /root/java
cd /root/java
vim Dockerfile
- FROM centos:7
- run yum -y install java-1.8.0
- WORKDIR /opt
- COPY ./ruoyi-admin.jar /opt
- CMD [ "lava","-jar","ruoyi-admin.jar" ]
- [root@localhost ~]# docker pull mysql:5.7
- [root@localhost ~]# docker pull redis
- [root@localhost ~]# docker pull nginx:1.25.3
- # For more information on configuration, see:
- # * Official English Documentation: http://nginx.org/en/docs/
- # * Official Russian Documentation: http://nginx.org/ru/docs/
-
- user nginx;
- worker_processes auto;
- error_log /var/log/nginx/error.log;
- pid /run/nginx.pid;
-
- # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
- include /usr/share/nginx/modules/*.conf;
- events {
- worker_connections 1024;
- }
- http {
- log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- access_log /var/log/nginx/access.log main;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- keepalive_timeout 65;
- types_hash_max_size 4096;
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
- # Load modular configuration files from the /etc/nginx/conf.d directory.
- # See http://nginx.org/en/docs/ngx_core_module.html#include
- # for more information.
- #include /etc/nginx/conf.d/*.conf;
- server {
- listen 80;
- server_name localhost;
- location / {
- root /usr/share/nginx/html;
- index index.html;
- }
- location /prod-api/ {
- proxy_pass http://java.com:8080/;
- }
- }
- # Settings for a TLS enabled server.
- #
- # server {
- # listen 443 ssl http2;
- # listen [::]:443 ssl http2;
- # server_name _;
- # root /usr/share/nginx/html;
- #
- # ssl_certificate "/etc/pki/nginx/server.crt";
- # ssl_certificate_key "/etc/pki/nginx/private/server.key";
- # ssl_session_cache shared:SSL:1m;
- # ssl_session_timeout 10m;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- #
- # # Load configuration files for the default server block.
- # include /etc/nginx/default.d/*.conf;
- #
- # error_page 404 /404.html;
- # location = /40x.html {
- # }
- #
- # error_page 500 502 503 504 /50x.html;
- # location = /50x.html {
- # }
- # }
- }

- version: '3'
- services:
- ruoyi-web:
- image: nginx:1.25.3
- container_name: ruoyi-web
- hostname: ruoyi-web
- environment:
- - LANG=C.UTF-8
- - LC_ALL=C.UTF-8
- ports:
- - 8888:80
- volumes:
- - ./RuoYi-Vue/ruoyi-ui/dist/:/usr/share/nginx/html/
- - ./nginx.conf:/etc/nginx/nginx.conf:ro
- links:
- - java:java.com
- depends_on:
- - java
- java:
- build: ./java
- container_name: java.server
- hostname: java
- environment:
- - LANG=C.UTF-8
- - LC_ALL=C.UTF-8
- links:
- - db:mysql.server
- - redis:redis.server
- depends_on:
- - db
- - redis
- db:
- image: mysql:5.7
- container_name: mysql.server
- hostname: db
- environment:
- - MYSQL_ROOT_PASSWORD=123456
- - MYSQL_DATABASE=ry-vue
- - LANG=C.UTF-8
- - LC_ALL=C.UTF-8
- command:
- - --character-set-server=utf8mb4
- - --collation-server=utf8mb4_general_ci
- volumes:
- - /opt/mysql-data4:/var/lib/mysql
- - ./RuoYi-Vue/sql:/docker-entrypoint-initdb.d
- redis:
- image: redis
- container_name: redis.server
- hostname: redis:redis.server
- environment:
- - LANG=C.UTF-8
- - LC_ALL=C.UTF-8

cd /root/ruoyi目录下
[root@localhost ruoyi]# docker compose up
10.12.153.93:8888
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。