如何将SpringBoot Java应用程序部署到云运行中?
我尝试使用以下链接https://cloud.google.com/run/docs/quickstarts/build-and-deploy/java
但是在上面的教程中,他们指定了jar文件。
Jave 8,SpringBoot 2.3.0. project版本正在此项目中使用。
发布于 2021-06-12 10:34:18
我们可以使用相同的教程成功地将springboot应用程序部署到云运行。https://cloud.google.com/run/docs/quickstarts/build-and-deploy/java
war包的Dockerfile配置
# Use the official maven/Java 8 image to create a build artifact.
# https://hub.docker.com/_/maven
FROM maven:3.8-jdk-11 as builder
# Copy local code to the container image.
WORKDIR /app
COPY pom.xml .
COPY src ./src
# Build a release artifact.
RUN mvn package -DskipTests
# Use AdoptOpenJDK for base image.
# It's important to use OpenJDK 8u191 or above that has container support enabled.
# https://hub.docker.com/r/adoptopenjdk/openjdk8
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM adoptopenjdk/openjdk11:alpine-slim
# Copy the jar to the production image from the builder stage.
COPY --from=builder /app/target/helloworld-*.war/helloworld.war
# Run the web service on container startup.
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/helloworld.war"]是我干的!
Note:不需要将包名从war更改为jar。
https://stackoverflow.com/questions/67778560
复制相似问题