docker compose微服务项目
Az-Xm 人气:01.数据库迁移
将cloud-demo涉及的相关sql导入到Linux上的mysql容器中
2.阅读docker-compose.yml文件
version: "3.2" services: nacos: image: nacos/nacos-server:1.4.1 environment: MODE: standalone ports: - "8848:8848" mysql: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: root volumes: - "/tmp/mysql/data:/var/lib/mysql" - "/tmp/mysql/conf/hmy.cnf:/etc/mysql/conf.d/my.cnf" ports: - "3306:3306" userservice: build: ./user-service depends_on: - nacos - mysql ports: - "8081:8081" orderservice: build: ./order-service depends_on: - nacos - mysql ports: - "8080:8080" gateway: build: ./gateway depends_on: - nacos - mysql ports: - "10010:10010"
3.将项目打包
pom.xml文件
<build> <finalName>app</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
配置文件
# 所有连接mysql的地方都要修改为mysql的容器名称(需要添加端口号)
# 所有连接nacos的地方都要修改为nacos的容器名称(需要添加端口号)
加载全部内容