在Docker中创建多程序集时遇到问题。我收到此错误,错误为jarfile无效或损坏
FROM openjdk:18-jdk-alpine AS build
ARG JAR_FILE
COPY ${JAR_FILE} /app/app.jar
COPY . /app/source
WORKDIR /app/source
EXPOSE 8001
FROM openjdk:18-jdk-alpine AS runtime
COPY --from=build /app/source/ /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
1条答案
按热度按时间ctehm74n1#
manifest.mf
Manifest-version: 1.0
Main-Class: Main
FROM eclipse-temurin:17.0.5_8-jdk-ubi9-minimal AS build
WORKDIR /tmp/app
COPY src /tmp/app/src
RUN mkdir -p /tmp/out
RUN javac -d /tmp/out src/.java
RUN cp /tmp/app/src/manifest.mf /tmp/out/manifest.mf
RUN ls /tmp/out/
RUN cd /tmp/out/ && jar cfm /tmp/app/app.jar manifest.mf Main.class Player.class VARIANTS.class
FROM eclipse-temurin:17.0.5_8-jre-ubi9-minimal
WORKDIR /APP
COPY --from=build /tmp/app/app.jar /APP/app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
docker build -t taskone:1.0.0 . docker tag taskone:1.0.0 taskone:latest
docker run -it taskone
docker images | grep taskone
jar cfm /tmp/app/app.jar manifest.mf Main.class Player.class VARIANTS.class
Dockerfile
I already test OK in my machine.