我尝试在Cloud Run上运行micronaut框架以测试土块启动性能。
在命令行中部署时,会出现以下问题:
Deploying...
Creating Revision... Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information....failed
Deployment failed
ERROR: (gcloud.beta.run.deploy) Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.
但是,我测试了几种dockerfile配置,并且我认为我的最后一个配置很适合将EnvVar端口传递给预期的Micronaut EnvVar:
FROM gradle:jdk11-slim as builder
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle build
FROM adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim
COPY --from=builder /home/gradle/src/build/libs/micronaut-jib-cr*.jar micronaut-jib-cr.jar
ENV MICRONAUT_SERVER_PORT=${PORT}
EXPOSE ${PORT}
CMD java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Dcom.sun.management.jmxremote -noverify ${JAVA_OPTS} -jar micronaut-jib-cr.jar
因此,我深入研究了Cloud Run日志,并且看到了造成此问题的另一个原因
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x8,0x1,0xc,0x2ae1273fc05c,0x4,0x32)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x8,0x6,0x6,0x2ae1273fc03c,0x4,0x3a)
A Error: Could not find or load main class micronaut.jib.cr.Application
A Caused by: java.lang.ClassNotFoundException: micronaut.jib.cr.Application
D Container Sandbox Limitation: Unsupported syscall semctl(0x1,0x0,0x2,0x2ae12753ef50,0x2,0x2ae12753ef50)
D Container Sandbox Limitation: Unsupported syscall semctl(0x1,0x0,0x2,0x2ae12753ef50,0x2,0x2ae12753ef50)
D Container Sandbox Limitation: Unsupported syscall semctl(0x1,0x0,0x2,0x2ae12753f440,0x2,0x2ae12753f440)
D Container Sandbox Limitation: Unsupported syscall semctl(0x1,0x0,0x2,0x2ae12753f440,0x2,0x2ae12753f440)
D Container Sandbox Limitation: Unsupported syscall semctl(0x1,0x0,0x2,0x2ae12753f440,0x2,0x2ae12753f440)
D Container Sandbox Limitation: Unsupported syscall semctl(0x1,0x0,0x2,0x2ae12753f440,0x2,0x2ae12753f440)
使用端口是否真的错误?在这种情况下,您能帮我处理我的dockerfile吗?
如果不是,这是已知的Cloud Run限制吗?
在micronaut上有一种变通方法可以解决此系统调用限制吗?
感谢您的帮助
答案 0 :(得分:0)
这不是端口问题。您似乎遇到了gvisor的限制,这是Cloud Run使用的沙箱。您的容器正在尝试进行系统调用,表明沙箱尚不支持,这导致容器在启动期间崩溃。
答案 1 :(得分:0)
的确,约翰·汉利(John Hanley)是对的。我的gradle版本没有引用正确的主类...我为这个明显的错误感到羞耻。但是我第一次使用Visual Studio Code(因为它看起来很时髦!),并且包重构的效率不如IntelliJ! (或者我没有正确的插件!)
感谢您的帮助,现在它可以完美运行(并且在GraalVM包装中再次发挥作用!)