当前位置: 首页 > news >正文

简单部署vue+springboot项目

vue

参考博客

先将vue项目打包

npm run build 

再创建项目文件夹front,在front中新建nginx.conf

server {listen      80;server_name  localhost;# 请求体的大小限制client_max_body_size 50m;# 日志文件存放地址access_log  /var/log/nginx/host.access.log  main;error_log  /var/log/nginx/error.log  error;# 代理前端项目文件location / {root   /usr/share/nginx/html;index  index.html index.htm;try_files $uri $uri/ /index.html;}# 代理后端服务地址 192.168.200.100:50000为后端服务地址location /api/ {proxy_pass http://192.168.200.100:50000/;}# 代理后端websocket服务地址location ^~ /wpi/ {proxy_pass http://192.168.200.100:50000/;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}  
}

在front中添加Dockerfile

FROM nginx
# 将dist文件拷贝到容器内的 /usr/share/nginx/html
COPY dist/ /usr/share/nginx/html
# 将nginx.conf文件拷贝到容器中nginx的默认配置文件存放目录下
COPY nginx.conf /etc/nginx/conf.d/default.conf 

创建镜像

docker build -t front .

运行容器

docker run --name front --restart=always -p 0.0.0.0:8080:80 -d front

springboot

在有启动类的模块pom里这样引入打包插件

<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.3.9.RELEASE</version><configuration><mainClass>org.nowiam.user.UserApplication</mainClass></configuration></plugin></plugins></build>

工具类里引入打包插件

<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.3.9.RELEASE</version><configuration><skip>true</skip></configuration></plugin></plugins></build>

根据项目关系依次install

最后target中就有打包好的jar包

创建文件夹将jar包放入该文件夹中

创建Dockerfile

#自动拉取镜像
FROM openjdk:8
#作者
MAINTAINER nowiam
#对外暴露的端口号
EXPOSE 50000ADD nowiam-gateway.jar /app.jar 
#运行的方式
ENTRYPOINT ["java","-jar","/app.jar"]

创建镜像

docker build -t nowiam-gateway .

运行容器

docker run --name nowiam-gateway --restart=always -p 0.0.0.0:50000:50000 -d nowiam-gateway


http://www.mrgr.cn/news/44211.html

相关文章:

  • CSS基础-常见属性(二)
  • C++的STL标准模版库容器--list类
  • 【d60】【Java】【力扣】509. 斐波那契数
  • ‌在Python中,print(f‘‘)是什么?
  • Bluetooth Channel Sounding中关于CS Procedure的详细介绍
  • MySql的基本语法操作
  • class 031 位运算的骚操作
  • 【Linux】线程的概念
  • CMake构建工程基本要素
  • Linux基础项目开发1:量产工具——显示系统
  • windows C++-创建基于代理的应用程序(上)
  • C++ 类与对象——超详细入门指南(上篇)
  • 【GeekBand】C++设计模式笔记6_Decorator_装饰模式
  • 【前端】-音乐播放器(源代码和结构讲解,大家可以将自己喜欢的歌曲添加到数据当中,js实现页面动态显示音乐)
  • expressjs,MySQL,实现分页查询接口
  • Vue - 打包部署
  • 如何避免任务延误:从原因到策略的全面解析
  • 18448 最小生成树
  • 使用树莓派搭建音乐服务器
  • AI配音(声音克隆)