From b25ed7aae475f5452cce3dbecc4ab5839e93cd66 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 6 Mar 2024 10:37:47 +0100 Subject: [PATCH 1/3] fix: make libretranslate with ipv6 --- docker/Dockerfile | 2 +- docker/arm.Dockerfile | 2 +- docker/cuda.Dockerfile | 2 +- scripts/healthcheck.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e883afd..8787b57 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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", "::" ] diff --git a/docker/arm.Dockerfile b/docker/arm.Dockerfile index f60c8ad..934df26 100644 --- a/docker/arm.Dockerfile +++ b/docker/arm.Dockerfile @@ -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", "::" ] diff --git a/docker/cuda.Dockerfile b/docker/cuda.Dockerfile index 1b29547..3ab10a1 100644 --- a/docker/cuda.Dockerfile +++ b/docker/cuda.Dockerfile @@ -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", "::" ] diff --git a/scripts/healthcheck.py b/scripts/healthcheck.py index 07bcaa4..aa5fcaf 100644 --- a/scripts/healthcheck.py +++ b/scripts/healthcheck.py @@ -1,7 +1,7 @@ import requests response = requests.post( - url='http://0.0.0.0:5000/translate', + url='http://[::1]:5000/translate', headers={'Content-Type': 'application/json'}, json={ 'q': 'Hello World!', From 732e984382d424ceeab2c9e32ea160d770180d9e Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 6 Mar 2024 15:46:29 +0100 Subject: [PATCH 2/3] fix: make libretranslate with ipv6 --- libretranslate/main.py | 4 ++++ scripts/healthcheck.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libretranslate/main.py b/libretranslate/main.py index 8337c70..6866a55 100644 --- a/libretranslate/main.py +++ b/libretranslate/main.py @@ -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: diff --git a/scripts/healthcheck.py b/scripts/healthcheck.py index aa5fcaf..2f0d22f 100644 --- a/scripts/healthcheck.py +++ b/scripts/healthcheck.py @@ -1,7 +1,7 @@ import requests response = requests.post( - url='http://[::1]:5000/translate', + url='http://localhost:5000/translate', headers={'Content-Type': 'application/json'}, json={ 'q': 'Hello World!', From 3bfb8342a0ced779d51e6a1a42f10f7d2c788f4c Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 6 Mar 2024 16:30:28 +0100 Subject: [PATCH 3/3] fix: also change entrypoint --- docker/Dockerfile | 2 +- docker/arm.Dockerfile | 2 +- docker/cuda.Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 8787b57..a785bed 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -42,4 +42,4 @@ RUN if [ "$with_models" = "true" ]; then \ fi EXPOSE 5000 -ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "::" ] +ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "*" ] diff --git a/docker/arm.Dockerfile b/docker/arm.Dockerfile index 934df26..8a6831e 100644 --- a/docker/arm.Dockerfile +++ b/docker/arm.Dockerfile @@ -40,4 +40,4 @@ RUN if [ "$with_models" = "true" ]; then \ fi EXPOSE 5000 -ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "::" ] +ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "*" ] diff --git a/docker/cuda.Dockerfile b/docker/cuda.Dockerfile index 3ab10a1..a9d44ae 100644 --- a/docker/cuda.Dockerfile +++ b/docker/cuda.Dockerfile @@ -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", "::" ] +ENTRYPOINT [ "libretranslate", "--host", "*" ]