1、项目地址
https://gitee.com/hhll/blog-hangliang.git
2、打包docker镜像并上传docker hub
【1】注册docker hub账号https://hub.docker.com/
【2】在docker hub建对应的仓库
【3】登录docker hub并打包上传前后端镜像
sudo docker login -u xxxx 密码 xxxxxx
后端:先将jar包替换
docker build -t="blgserver" .
sudo docker tag blgserver huanl250/myblog-server:1.2
sudo docker push huanl250/myblog-server:1.2
前端:先将dist替换
docker build -t="blgfront" .
sudo docker tag blgfront huanl250/myblog-front:1.0
sudo docker push huanl250/myblog-front:1.0
sudo docker pull huanl250/myblog-front:1.0
本地docker目录结构
3、腾讯云服务器配置
【1】购买服务器,装带docker的ubuntu系统
【2】登录系统检查环境
【3】编写docker compose文件
version: '3'
services:front:image: huanl250/myblog-front:latestrestart: "always"privileged: truecontainer_name: compose-frontappports:- "8080:80"web:image: serverapp:latestrestart: "always"privileged: truecontainer_name: compose-serverappenvironment:SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/my_blog?serverTimezone=GMT%2B8&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&rewriteBatchedStatements=trueSPRING_DATASOURCE_USERNAME: rootSPRING_DATASOURCE_PASSWORD: xxxxxSPRING_PROFILES_ACTIVE: testMINIO_ENDPOINT: http://43.143.89.220:9000MINIO_SAVEFILEPATH: /home/temp1/MINIO_unZipFilePath: /home/temp/MINIO_PASSWORD: root123456MINIO_USERNAME: rootMINIO_BUCKET: testports:- "38080:8080"links:- mysql- miniodepends_on:- mysql- miniomysql:image: mysqlrestart: "always"privileged: truecontainer_name: compose-mysqlports:- "33306:3306"environment:MYSQL_ROOT_PASSWORD: xxxxxvolumes:- /home/huangliang/mysql/data:/var/lib/mysql- /home/huangliang/mysql/config:/etc/mysql/conf.d- /home/huangliang/mysql/logs:/var/log/mysqlminio:image: minio/miniorestart: "always"privileged: truecontainer_name: compose-minioports:- "9000:9000"- "9001:9001"volumes:- /home/huangliang/minio/data:/dataenvironment:MINIO_ROOT_USER: rootMINIO_ROOT_PASSWORD: xxxxxcommand: server /data --console-address ":9001"
【4】启动服务
sudo docker-compose down
sudo docker-compose up -d
如果是用同一个版本号需要先docker pull
4、访问网站
【1】放开访问端口
【2】通过ip+端口访问
http://43.143.89.220:8080/huangl-blg-front/#/