【问题标题】:Deploy Tomcat/Docker Hello-World to Heroku returning HTTP:503将 Tomcat/Docker Hello-World 部署到 Heroku,返回 HTTP:503
【发布时间】:2021-08-13 01:20:38
【问题描述】:

我承认我有点担心使用这个位于 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

过程文件:

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

【问题讨论】:

    标签: docker heroku tomcat9


    【解决方案1】:

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

    查看:https://stormy-wildwood-00412.herokuapp.com/index.jsp

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

    【讨论】:

      猜你喜欢
      • 2021-02-12
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      • 2020-09-09
      • 2018-02-05
      • 1970-01-01
      • 2017-11-19
      相关资源
      最近更新 更多