I try to build a Maven project using dockerfile, but I got this error when I used command docker build
:
/bin/sh: 1: ./mvnw: not found
I have tried this solution: Unable to run './mvnw clean install' when building docker image based on "openjdk:8-jdk-alpine" for Spring Boot app
But I still got an error.
Here is my dockerfile:
# Stage 1 Build the Spring Project into a JAR file
FROM openjdk:8-slim as builder
RUN mkdir src
COPY . /src
WORKDIR /src
RUN chmod 700 mvnw && ./mvnw clean install package ==> An error on this line
# Stage 2 Run the JAR file from the previous build
FROM openjdk:8-jdk-alpine
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
COPY --from=builder /src/target /build
WORKDIR /build
EXPOSE 80
EXPOSE 5001
ENTRYPOINT ["java", "-jar", "tax-0.0.1-SNAPSHOT.jar"]
Am I missing something?