Skip to content

Commit

Permalink
Merge pull request #596 from cyrinux/fix/ipv6-compat
Browse files Browse the repository at this point in the history
fix: make libretranslate works with ipv6
  • Loading branch information
pierotofy committed Mar 6, 2024
2 parents 74a7831 + 3bfb834 commit 6ae0091
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Expand Up @@ -42,4 +42,4 @@ RUN if [ "$with_models" = "true" ]; then \
fi

EXPOSE 5000
ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "0.0.0.0" ]
ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "*" ]
2 changes: 1 addition & 1 deletion docker/arm.Dockerfile
Expand Up @@ -40,4 +40,4 @@ RUN if [ "$with_models" = "true" ]; then \
fi

EXPOSE 5000
ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "0.0.0.0" ]
ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "*" ]
2 changes: 1 addition & 1 deletion docker/cuda.Dockerfile
Expand Up @@ -42,4 +42,4 @@ RUN pip3 install Babel==2.12.1 && python3 scripts/compile_locales.py \
# ENV LD_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/cuda/lib64

EXPOSE 5000
ENTRYPOINT [ "libretranslate", "--host", "0.0.0.0" ]
ENTRYPOINT [ "libretranslate", "--host", "*" ]
4 changes: 4 additions & 0 deletions libretranslate/main.py
Expand Up @@ -215,6 +215,10 @@ def main():
if '--wsgi' in sys.argv:
return app
else:
if args.debug and args.host == "*":
# '::' will listen on both ipv6 and ipv4
args.host = "::"

if args.debug:
app.run(host=args.host, port=args.port)
else:
Expand Down
2 changes: 1 addition & 1 deletion scripts/healthcheck.py
@@ -1,7 +1,7 @@
import requests

response = requests.post(
url='http://0.0.0.0:5000/translate',
url='http://localhost:5000/translate',
headers={'Content-Type': 'application/json'},
json={
'q': 'Hello World!',
Expand Down

0 comments on commit 6ae0091

Please sign in to comment.