将 Tomcat/Docker Hello-World 部署到 Heroku,返回 HTTP:503

时间:2021-05-24 18:24:20

标签: docker heroku tomcat9

我承认我在使用这个位于 Tomcat 容器内的小应用程序管理端口配置时有些杂草丛生。

我知道 TC 监听 8080。我认为,只要 Heroku 提供的任何端口映射到容器中的 8080,请求至少应该到达容器。我已尝试相应地遵循他们的指示。不知道为什么需要 webapp-runner 但 Heroku 指定了它。

但是,在本地开发时(在它工作正常的地方),请求中指定了目标战争的名称(即http://127.0.0.1:8080/DockerJavaWebApp-1.0-SNAPSHOT/)。我不确定如何做到这一点,或者如果有必要,在部署中。而且我也宁愿不必在本地进行。

提前感谢任何帮助。

Dockerfile:

FROM tomcat
ADD target/DockerJavaWebApp-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/
EXPOSE 8080
CMD ["catalina.sh", "run" , "-b", "0.0.0.0:$PORT"]

docker-compose:

version: '3'

services:
  app:
    build: .
    image: yermammy #tomcat_test
    environment:
      - PORT

Procfile:

web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war

heroku 日志(已省略): (该端口映射看起来是否具有正确的语法?)

2021-05-25T00:39:16.515638+00:00 heroku[web.1]: Starting process with command `catalina.sh run -b 0.0.0.0:\48915`

2021-05-24T18:04:27.398894+00:00 app[web.1]: 24-May-2021 18:04:27.398 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [6388] milliseconds

2021-05-24T18:05:07.025452+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=blah-tomcat-test.herokuapp.com request_id=0b87e97e-ca2f-4406-b4f2-329890f923db fwd="65.35.200.119" dyno= connect= service= status=503 bytes= protocol=https

2021-05-24T18:05:07.725522+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

2021-05-24T18:05:07.785462+00:00 heroku[web.1]: Stopping process with SIGKILL

2021-05-24T18:05:08.146910+00:00 heroku[web.1]: Process exited with status 137
2021-05-24T18:05:08.219013+00:00 heroku[web.1]: State changed from starting to crashed

2021-05-24T18:05:10.482493+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=blah-tomcat-test.herokuapp.com request_id=d328a542-0466-4be5-9a82-1eda0cb42af4 fwd="65.35.200.119" dyno= connect= service= status=503 bytes= protocol=https

2021-05-24T18:05:12.259286+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=blah-tomcat-test.herokuapp.com request_id=c2172b8c-4a66-491d-9db1-86685a4f6662 fwd="65.35.200.119" dyno= connect= service= status=503 bytes= protocol=https

2021-05-24T18:05:27.529565+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/index.jsp" host=blah-tomcat-test.herokuapp.com request_id=38a21675-c542-46a1-8692-1672547b6f02 fwd="65.35.200.119" dyno= connect= service= status=503 bytes= protocol=https

2021-05-24T18:05:27.951191+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=blah-tomcat-test.herokuapp.com request_id=7cba1f7a-abdf-43c0-bba7-dd7341e4daee fwd="65.35.200.119" dyno= connect= service= status=503 bytes= protocol=https

1 个答案:

答案 0 :(得分:0)

当通过这些指令 (https://devcenter.heroku.com/articles/java-webapp-runner#prerequisites) 部署时,war 文件运行良好——这些指令规定使用 GIT。

检查一下:https://stormy-wildwood-00412.herokuapp.com/index.jsp

但是,包含该应用程序的 docker 映像无法与 Heroku 提供的端口连接。