OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

LibreTranslate deployment to Heroku using docker : Error R10 (Boot timeout)

  • Thread starter Thread starter Bassel
  • Start date Start date
B

Bassel

Guest
I'm trying to deploy LibreTranslate, a Python Flask application using Docker on Heroku, but I keep running into a boot timeout error. The application works perfectly when I run it locally using Docker, but when I deploy it to Heroku, it fails to bind to the port within 60 seconds, resulting in an R10 error.

Error Log from Heroku:

Code:
2024-06-22T01:11:17.161226+00:00 heroku[web.1]: Starting process with command `/bin/sh -c /app/run.sh`
2024-06-22T01:11:17.801391+00:00 app[web.1]: Starting LibreTranslate...
2024-06-22T01:11:17.801440+00:00 app[web.1]: PORT: 59962
2024-06-22T01:11:17.801441+00:00 app[web.1]: Using port: 59962
2024-06-22T01:12:17.387183+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2024-06-22T01:12:17.399589+00:00 heroku[web.1]: Stopping process with SIGKILL
2024-06-22T01:12:17.487780+00:00 heroku[web.1]: Process exited with status 137

Dockerfile:

Code:
FROM python:3.11.9-slim-bullseye as builder

WORKDIR /app

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
  && apt-get -qqq install --no-install-recommends -y pkg-config gcc g++ \
  && apt-get upgrade --assume-yes \
  && apt-get clean \
  && rm -rf /var/lib/apt

RUN python -m venv venv && ./venv/bin/pip install --no-cache-dir --upgrade pip

COPY . .

# Install package from source code, compile translations
RUN ./venv/bin/pip install Babel==2.12.1 && ./venv/bin/python scripts/compile_locales.py \
  && ./venv/bin/pip install torch==2.0.1 --extra-index-url https://download.pytorch.org/whl/cpu \
  && ./venv/bin/pip install . \
  && ./venv/bin/pip cache purge

FROM python:3.11.9-slim-bullseye

ARG with_models=false
ARG models=""

RUN addgroup --system --gid 1032 libretranslate && adduser --system --uid 1032 libretranslate && mkdir -p /home/libretranslate/.local && chown -R libretranslate:libretranslate /home/libretranslate/.local
USER libretranslate

COPY --from=builder --chown=1032:1032 /app /app
WORKDIR /app

COPY --from=builder --chown=1032:1032 /app/venv/bin/ltmanage /usr/bin/

RUN if [ "$with_models" = "true" ]; then  \
  # initialize the language models
  if [ ! -z "$models" ]; then \
  ./venv/bin/python scripts/install_models.py --load_only_lang_codes "$models";   \
  else \
  ./venv/bin/python scripts/install_models.py;  \
  fi \
  fi

# Set the ENTRYPOINT to ensure that the run.sh script is executed with the correct interpreter
ENTRYPOINT ["/bin/bash", "/app/run.sh"]

run.sh:

Code:
#!/bin/bash
set -eo pipefail

echo "Starting LibreTranslate..."
echo "PORT: ${PORT}"

./venv/bin/libretranslate --host 0.0.0.0 --port $PORT &> /app/libretranslate.log 2>&1

The application is supposed to run a Flask server using the LibreTranslate library, and I've set it to bind to 0.0.0.0 with the port provided by Heroku's environment variable $PORT.

  • Could the 0.0.0.0 binding be incorrect for Heroku's environment?
  • What can I do to further diagnose why the application fails to bind to the port within the allowed time?
  • Are there any known issues with Flask or Docker configurations that could cause this delay in binding to the port?
<p>I'm trying to deploy LibreTranslate, a Python Flask application using Docker on Heroku, but I keep running into a boot timeout error. The application works perfectly when I run it locally using Docker, but when I deploy it to Heroku, it fails to bind to the port within 60 seconds, resulting in an R10 error.</p>
<p>Error Log from Heroku:</p>
<pre><code>2024-06-22T01:11:17.161226+00:00 heroku[web.1]: Starting process with command `/bin/sh -c /app/run.sh`
2024-06-22T01:11:17.801391+00:00 app[web.1]: Starting LibreTranslate...
2024-06-22T01:11:17.801440+00:00 app[web.1]: PORT: 59962
2024-06-22T01:11:17.801441+00:00 app[web.1]: Using port: 59962
2024-06-22T01:12:17.387183+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2024-06-22T01:12:17.399589+00:00 heroku[web.1]: Stopping process with SIGKILL
2024-06-22T01:12:17.487780+00:00 heroku[web.1]: Process exited with status 137
</code></pre>
<p>Dockerfile:</p>
<pre><code>FROM python:3.11.9-slim-bullseye as builder

WORKDIR /app

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get -qqq install --no-install-recommends -y pkg-config gcc g++ \
&& apt-get upgrade --assume-yes \
&& apt-get clean \
&& rm -rf /var/lib/apt

RUN python -m venv venv && ./venv/bin/pip install --no-cache-dir --upgrade pip

COPY . .

# Install package from source code, compile translations
RUN ./venv/bin/pip install Babel==2.12.1 && ./venv/bin/python scripts/compile_locales.py \
&& ./venv/bin/pip install torch==2.0.1 --extra-index-url https://download.pytorch.org/whl/cpu \
&& ./venv/bin/pip install . \
&& ./venv/bin/pip cache purge

FROM python:3.11.9-slim-bullseye

ARG with_models=false
ARG models=""

RUN addgroup --system --gid 1032 libretranslate && adduser --system --uid 1032 libretranslate && mkdir -p /home/libretranslate/.local && chown -R libretranslate:libretranslate /home/libretranslate/.local
USER libretranslate

COPY --from=builder --chown=1032:1032 /app /app
WORKDIR /app

COPY --from=builder --chown=1032:1032 /app/venv/bin/ltmanage /usr/bin/

RUN if [ "$with_models" = "true" ]; then \
# initialize the language models
if [ ! -z "$models" ]; then \
./venv/bin/python scripts/install_models.py --load_only_lang_codes "$models"; \
else \
./venv/bin/python scripts/install_models.py; \
fi \
fi

# Set the ENTRYPOINT to ensure that the run.sh script is executed with the correct interpreter
ENTRYPOINT ["/bin/bash", "/app/run.sh"]

</code></pre>
<p>run.sh:</p>
<pre><code>#!/bin/bash
set -eo pipefail

echo "Starting LibreTranslate..."
echo "PORT: ${PORT}"

./venv/bin/libretranslate --host 0.0.0.0 --port $PORT &> /app/libretranslate.log 2>&1
</code></pre>
<p>The application is supposed to run a Flask server using the LibreTranslate library, and I've set it to bind to 0.0.0.0 with the port provided by Heroku's environment variable $PORT.</p>
<ul>
<li>Could the 0.0.0.0 binding be incorrect for Heroku's environment?</li>
<li>What can I do to further diagnose why the application fails to bind to the port within the allowed time?</li>
<li>Are there any known issues with Flask or Docker configurations that could cause this delay in binding to the port?</li>
</ul>
 

Latest posts

A
Replies
0
Views
1
Ashrik Ahamed
A
A
Replies
0
Views
1
Ashrik Ahamed
A

Online statistics

Members online
1
Guests online
4
Total visitors
5
Top