我正在尝试使用Docker在Heroku上部署一个Spring Boot应用程序。构建.war文件和Docker映像时,构建都是成功的。我不完全确定问题在哪里。
我尝试在docker文件中定义< code>EXPOSE 80,< code>ENV PORT=80,但也不起作用。我尝试在我的配置文件application-prod.yml中定义端口,但是没有成功。我还应该在这里寻找什么,我和Spring Boot一起在Heroku部署时错过了什么吗?
错误消息:
错误R10(启动超时)-
这是我的泊坞文件:
FROM tomcat:jdk16-openjdk-slim
# Java options
ENV JAVA_TOOL_OPTIONS="-Xms100M -Xmx100M -Dspring.profiles.active=prod -Dserver.port=80"
ENV PORT=80
# Firebase Config
ENV GOOGLE_APPLICATION_CREDENTIALS=./src/main/resources/firebase.json
# War file for Tomcat
ARG WAR_FILE=/build/libs/mefit-0.0.1-SNAPSHOT.war
RUN rm -rf /usr/local/tomcat/webapps/*
COPY ${WAR_FILE} /usr/local/tomcat/webapps/ROOT.war
ENV CATALINA_OPTS="-Xms100M -Xmx100M"
EXPOSE 80
CMD ["catalina.sh", "run"]
这是来自Heroku的日志:
021-09-20T12:34:35.702071+00:00 heroku[web.1]: Starting process with command `catalina.sh run`
2021-09-20T12:34:36.462169+00:00 app[web.1]: NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
2021-09-20T12:34:36.463899+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xms100M -Xmx100M -Dspring.profiles.active=prod -Dserver.port=80
2021-09-20T12:34:36.886149+00:00 app[web.1]: 20-Sep-2021 12:34:36.877 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/10.0.11
2021-09-20T12:34:36.886476+00:00 app[web.1]: 20-Sep-2021 12:34:36.886 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Sep 6 2021 16:22:12 UTC
2021-09-20T12:34:36.886714+00:00 app[web.1]: 20-Sep-2021 12:34:36.886 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.0.11.0
2021-09-20T12:34:36.886938+00:00 app[web.1]: 20-Sep-2021 12:34:36.886 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
2021-09-20T12:34:36.887167+00:00 app[web.1]: 20-Sep-2021 12:34:36.887 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 4.4.0-1095-aws
2021-09-20T12:34:36.887411+00:00 app[web.1]: 20-Sep-2021 12:34:36.887 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
2021-09-20T12:34:36.887620+00:00 app[web.1]: 20-Sep-2021 12:34:36.887 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/openjdk-16
2021-09-20T12:34:36.887812+00:00 app[web.1]: 20-Sep-2021 12:34:36.887 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 16.0.2+7-67
2021-09-20T12:34:36.888037+00:00 app[web.1]: 20-Sep-2021 12:34:36.887 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
2021-09-20T12:34:36.888247+00:00 app[web.1]: 20-Sep-2021 12:34:36.888 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
2021-09-20T12:34:36.888451+00:00 app[web.1]: 20-Sep-2021 12:34:36.888 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
2021-09-20T12:34:37.289288+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms100M
2021-09-20T12:34:37.289384+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx100M
2021-09-20T12:34:37.289485+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dspring.profiles.active=prod
2021-09-20T12:34:37.289594+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dserver.port=80
2021-09-20T12:34:37.289689+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
2021-09-20T12:34:37.289786+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
2021-09-20T12:34:37.289879+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
2021-09-20T12:34:37.289965+00:00 app[web.1]: 20-Sep-2021 12:34:37.289 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
2021-09-20T12:34:37.290048+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
2021-09-20T12:34:37.290139+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
2021-09-20T12:34:37.290224+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
2021-09-20T12:34:37.290296+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
2021-09-20T12:34:37.290385+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
2021-09-20T12:34:37.290466+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
2021-09-20T12:34:37.290546+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms100M
2021-09-20T12:34:37.290662+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx100M
2021-09-20T12:34:37.290743+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
2021-09-20T12:34:37.290827+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
2021-09-20T12:34:37.290905+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
2021-09-20T12:34:37.290985+00:00 app[web.1]: 20-Sep-2021 12:34:37.290 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
2021-09-20T12:34:37.294694+00:00 app[web.1]: 20-Sep-2021 12:34:37.294 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.31] using APR version [1.7.0].
2021-09-20T12:34:37.294793+00:00 app[web.1]: 20-Sep-2021 12:34:37.294 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
2021-09-20T12:34:37.297476+00:00 app[web.1]: 20-Sep-2021 12:34:37.297 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1k 25 Mar 2021]
2021-09-20T12:34:38.320649+00:00 app[web.1]: 20-Sep-2021 12:34:38.320 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
2021-09-20T12:34:38.344458+00:00 app[web.1]: 20-Sep-2021 12:34:38.344 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1669] milliseconds
2021-09-20T12:34:38.397136+00:00 app[web.1]: 20-Sep-2021 12:34:38.396 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
2021-09-20T12:34:38.397311+00:00 app[web.1]: 20-Sep-2021 12:34:38.397 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.0.11]
2021-09-20T12:34:38.411783+00:00 app[web.1]: 20-Sep-2021 12:34:38.411 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/ROOT.war]
2021-09-20T12:34:49.601670+00:00 app[web.1]: 20-Sep-2021 12:34:49.601 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2021-09-20T12:34:49.668340+00:00 app[web.1]: 20-Sep-2021 12:34:49.668 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/ROOT.war] has finished in [11,256] ms
2021-09-20T12:34:49.677006+00:00 app[web.1]: 20-Sep-2021 12:34:49.676 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
2021-09-20T12:34:49.688535+00:00 app[web.1]: 20-Sep-2021 12:34:49.687 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [11342] milliseconds
2021-09-20T12:35:35.854246+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-09-20T12:35:35.943021+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-09-20T12:35:36.135780+00:00 heroku[web.1]: Process exited with status 137
2021-09-20T12:35:36.414530+00:00 heroku[web.1]: State changed from starting to crashed
以下是我使用 Heroku CLI 部署应用程序的方式:
heroku container:push web --app my-app-name
heroku container:release web --app my-app-name
这是我正在使用的应用程序 prod.yml 文件:
spring:
main:
allow-bean-definition-overriding: true
jpa:
hibernate:
ddl-auto: update
generate-ddl: true
datasource:
url: ${URL}
username: ${USERNAME}
password: ${PASSWORD}
springdoc:
api-docs:
path: /v1/docs
swagger-ui:
path: /v1/docs/index.html
operationsSorter: method
security:
firebase-props:
database-url: ${FIREBASE_DB_URL}
enable-strict-server-session: false
enable-check-session-revoked: false
enable-logout-everywhere: false
session-expiry-in-days: 5
cookie-props:
max-age-in-minutes: 7200
http-only: true
secure: false
domain: localhost
path: /
allow-credentials: true
allowed-origins:
- http://localhost:4200
allowed-methods:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
allowed-headers:
- Authorization
- Origin
- Content-Type
- Accept
- Accept-Encoding
- Accept-Language
- Access-Control-Allow-Origin
- Access-Control-Allow-Headers
- Access-Control-Request-Method
- X-Requested-With
- X-Auth-Token
- X-Xsrf-Token
- Cache-Control
- Id-Token
exposed-headers:
- X-Xsrf-Token
allowed-public-apis:
- /favicon.ico
- /session/login
- /public/*
- /test/**
logging:
level:
root: WARN
org:
springframework:
web: DEBUG
hibernate: ERROR
pattern:
console: "%d{HH:mm:ss} || %highlight(%5p) < %highlight(%-35.35logger{35}) > %highlight(%m%n)"
你能给我看看你的Spring boot属性文件吗?我想看看你是否告诉Spring boot它的托管端口取决于一个环境变量。
1、自我介绍 2、你对游戏策划的了解 策划分为不同的工种,聊了系统策划、数值策划、文案策划、运营策划 3、项目1,你的制作过程和学习过程,问题怎么解决的 4、展示一下项目2(一个unity的DEMO) 由于unity项目打开比较慢,所以这里一边打开着一边问别的问题。 5、你最近在玩的游戏 6、举例一款游戏,吸引你的点 举例部落冲突,从游戏画面、体验、玩法三个角度答的。 部落冲突是一款SLG模拟策略
随着secrets.yml文件的发布,我摆脱了对Figaro的依赖,将所有的密钥都转移到secrets.yml中,并将该文件添加到. gitignore中。 但当我试图推赫罗库,赫罗库说,他们需要在我的回购文件,以部署网站。这很有道理,但是如果可以避免的话,我不希望我的键在git中。 使用费加罗,我将运行一个rake任务,将heroku的密钥部署为环境变量,并将application.yml保存在
我正在查看一个Rails应用程序,它需要建立远程SSH会话(SSH隧道?)从Heroku到远程Mysql数据库,作为后台ActiveRecord会话的一部分。目标是通过此通道在不同时间将数据迁移到应用程序中。无法通过web连接到远程mysql数据库。 几个问题: 赫鲁库允许SSH关闭他们的测功机吗? 这样做的缺点是什么? 我是否必须担心 SSH 会话持久性(作业可能需要 1 小时)? 最后,如何配
我正在一个使用贾斯珀报告的应用程序工作。它与莫哈拉一起使用Primefaces,并部署在码头。当我在本地部署应用时,它确实可以正常工作。但是当我在赫鲁库部署时,它不起作用。 当我把它部署到赫鲁库时,我得到: HTTP错误500 访问/clients.pdf时出现问题。原因: java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStre
我有一个在NeoVim中没有按预期发射的关键命令。下面是我neovim配置的摘录: 来自:nmap的适用条目显示绑定尚未被覆盖。 但按
我很难在服务器重新引导时重新启动pm2(它本身和两个节点/express文件,&)。 下面是我尝试的过程: 我在所有可能的组合中运行了上面的命令,但没有任何工作。我试着以根用户的身份运行,但也不起作用。 我的文件包含信息,所以我不知道还可以在哪里查找。 我尝试的其他参考资料... http://pm2.keymetrics.io/docs/usage/startup/ https://www.di