axxam commited on
Commit
c06bcbe
·
verified ·
1 Parent(s): aad1c54

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -30
Dockerfile CHANGED
@@ -1,30 +1,37 @@
1
- import os
2
- from huggingface_hub import HfApi
3
-
4
- SUGGESTIONS_FILE = "/app/suggestions/suggestions.jsonl"
5
- REPO_ID = "axxam/LibreTranslate_Kabyle"
6
-
7
- def upload():
8
- token = os.environ.get("HF_TOKEN")
9
- if not token:
10
- print("HF_TOKEN not set. Skipping upload.")
11
- return
12
- if not os.path.exists(SUGGESTIONS_FILE):
13
- print("No suggestions file found. Nothing to upload.")
14
- return
15
-
16
- api = HfApi()
17
- try:
18
- api.upload_file(
19
- path_or_fileobj=SUGGESTIONS_FILE,
20
- path_in_repo="suggestions/suggestions.jsonl",
21
- repo_id=REPO_ID,
22
- repo_type="space",
23
- token=token
24
- )
25
- print("Uploaded suggestions to Hugging Face repo.")
26
- except Exception as e:
27
- print(f"Upload failed: {e}")
28
-
29
- if __name__ == "__main__":
30
- upload()
 
 
 
 
 
 
 
 
1
+ FROM libretranslate/libretranslate
2
+
3
+ USER root
4
+
5
+ RUN apt-get update && apt-get install -y \
6
+ curl unzip git python3-pip
7
+
8
+ # Make writable folders
9
+ RUN mkdir -p /.local && chmod -R 777 /.local && \
10
+ mkdir -p /app/db/sessions && chmod -R 777 /app/db && \
11
+ mkdir -p /app/suggestions
12
+
13
+ ENV HOME=/app
14
+
15
+ # Download and install the Kabyle model
16
+ RUN curl -L -o /app/en_kab_comp.argosmodel \
17
+ https://huggingface.co/spaces/axxam/LibreTranslate_Kabyle/resolve/main/en_kab_comp.argosmodel && \
18
+ /app/venv/bin/python3 -c "import argostranslate.package; argostranslate.package.install_from_path('/app/en_kab_comp.argosmodel')"
19
+
20
+ # Install Hugging Face hub client
21
+ RUN /app/venv/bin/pip install huggingface_hub
22
+
23
+ # Copy uploader script
24
+ COPY upload_suggestions.py /app/upload_suggestions.py
25
+
26
+ # Set environment variables
27
+ ENV LT_HOST="0.0.0.0"
28
+ ENV LT_PORT="7860"
29
+ ENV LT_LOAD_ONLY="en,fr,kab_comp"
30
+ ENV LT_SSL=True
31
+ ENV LT_SUGGESTIONS="true"
32
+ ENV LT_REQ_LIMIT="100"
33
+ ENV LT_FRONTEND_LANGUAGE_SOURCE="en"
34
+ ENV LT_FRONTEND_LANGUAGE_TARGET="kab_comp"
35
+
36
+ # Entry: run LibreTranslate and suggestion uploader in parallel
37
+ CMD bash -c "/app/venv/bin/libretranslate & while true; do /app/venv/bin/python3 /app/upload_suggestions.py; sleep 60; done"