3.mysql 初始化需要的 sql 文件
FROM java:8 MAINTAINER fuwei<laofu_online@163.com> COPY oncesearch-portal-1.0-SNAPSHOT.jar /app.jar CMD ["--server.port=80"] EXPOSE 80 ENTRYPOINT ["java","-jar","/app.jar"]爬虫的文件
FROM java:8 MAINTAINER fuwei<laofu_online@163.com> COPY oncesearch-spider-1.0.0.jar /spider.jar ENTRYPOINT ["java","-jar","/spider.jar"]Compose 文件
version: "3.0" services: portal: build: dockerfile: Dockerfile context: . image: portal depends_on: - redis - mysql ports: - 80:80 spider: build: dockerfile: DockerfileSpider context: . image: spider depends_on: - redis - mysql redis: image: "library/redis:alpine" # 版本 mysql: image: "mysql:latest" environment: MYSQL_ROOT_PASSWORD: "Abc12345++++" MYSQL_USER: 'root' MYSQL_PASS: "Abc12345++++" volumes: # 挂载目录 - "./db:/var/lib/mysql" - "./conf/my.cnf:/etc/my.cnf" - "./init:/docker-entrypoint-initdb.d/" # 初始化的 sql \ ports: # 对内和对外的端口 - "3307:3306"最终文件的目录:
├── Dockerfile ├── DockerfileSpider ├── docker-compose.yml ├── init │ └── ITBlog.sql ├── oncesearch-portal-1.0-SNAPSHOT.jar └── oncesearch-spider-1.0.0.jar、
# DB 连接字符串,直接使用镜像的名称即可 url: jdbc:mysql://mysql:3306/ITBlog?serverTimezone=UTC最后直接执行 docker-compose执行打包部署。