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

简单部署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 50000
 
ADD 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.kler.cn/news/335269.html

相关文章:

  • 汽车革命下半场AI先锋:广汽为新“智”汽车装配大模型“底盘”
  • 计算机网络:三次握手和四次挥手详解
  • 使用NumPy进行线性代数的快速指南
  • Linux自动化构建工具Make/Makefile
  • 基于yolov8深度学习的120种犬类检测与识别系统python源码+onnx模型+评估指标曲线+精美GUI界面目标检测狗类检测犬类识别系统
  • 三维模型点云化工具V1.0使用介绍:将三维模型进行点云化生成
  • 笔记整理—linux进程部分(6)进程间通信、alarm和pause
  • 使用Pytorch构建自定义层并在模型中使用
  • 架构设计笔记-5-软件工程基础知识-3
  • 【Springdoc-openapi】基于SpringBoot3.3.x版本③集成Springdoc
  • windows C++-创建基于代理的应用程序(上)
  • 数据和算力共享
  • 【bash】删除本地所有分支
  • rabbitmq消费者应答模式
  • C++基础:enum class作用域枚举 (C++11)
  • 深度扩展AntSK,让.NET Aspire助力您的AI项目
  • Rust(2)进阶语法
  • MYSQL求月份同比数据和环比数据
  • 在 Koa 中,中间件函数的参数ctx是什么?
  • nodejs 构建高性能服务器的关键技术