我有一个 Dockerfile,它实际上正在构建一个 maven spring boot 项目。我的 docker-compose.yml 如下
version: '3'
services:
db:
image: mysql
restart: always
environment:
- MYSQL_DATABASE=calero
- MYSQL_ROOT_PASSWORD=root
volumes:
- ./db:/var/lib/mysql
ports:
- "3306:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
environment:
PMA_ARBITRARY: 1
MYSQL_ROOT_PASSWORD: root
ports:
- "8082:80"
links:
- "db:db"
redsparrow:
build: .
restart: always
ports:
- "8081:8080"
links:
- "db:db"
depends_on:
- db
volumes:
db:
driver: "local"
Dockerfile 就是这个
FROM maven:3.6.0-jdk-11 as build
WORKDIR /app
COPY . /app
RUN mvn clean package
FROM tomcat
COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
COPY tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
COPY tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
COPY --from=build /app/target/*.war /usr/local/tomcat/webapps
但是我在这里面临的 docker-compose 总是尝试在启动 mySQL 容器和 mvn clean 包之前尝试构建 redsparrow,因为它没有启动,所以构建不会成功。
我想我遗漏了一些东西,以便在数据库容器启动后始终构建 Spring Boot 应用程序(redsparrow)。
请帮忙!