Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +26 -35
Dockerfile
CHANGED
|
@@ -1,45 +1,36 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
-
build-essential \
|
| 9 |
-
pkg-config \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
-
# Create non-root user
|
| 13 |
-
RUN useradd -m -u 1000
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
ENV PATH="/home/libretranslate/venv/bin:$PATH"
|
| 23 |
|
| 24 |
-
# Install
|
| 25 |
-
RUN pip install --
|
| 26 |
-
pip install --no-cache-dir libretranslate gunicorn
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
RUN
|
| 30 |
-
if [ ! -z "$models" ]; then \
|
| 31 |
-
python -c "from argostranslate import package; from libretranslate import get_available_packages; [package.install_from_path(p) for p in get_available_packages() if any(lang in p for lang in '${models}'.split(','))]"; \
|
| 32 |
-
else \
|
| 33 |
-
libretranslate --update-models; \
|
| 34 |
-
fi \
|
| 35 |
-
fi
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
\n\
|
| 40 |
-
app = create_app()' > wsgi.py
|
| 41 |
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
-
# Run
|
| 45 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:
|
|
|
|
| 1 |
+
# Use Python 3.11 base image
|
| 2 |
+
FROM python:3.11
|
| 3 |
|
| 4 |
+
# Update system and install git and curl
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
git \
|
| 7 |
+
curl \
|
|
|
|
|
|
|
|
|
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
+
# Create a non-root user
|
| 11 |
+
RUN useradd -m -u 1000 appuser
|
| 12 |
+
|
| 13 |
+
# Clone LibreTranslate repository and set working directory
|
| 14 |
+
RUN git clone https://github.com/LibreTranslate/LibreTranslate.git
|
| 15 |
+
WORKDIR /LibreTranslate
|
| 16 |
|
| 17 |
+
# Change ownership of the application directory to the non-root user
|
| 18 |
+
RUN chown -R appuser:appuser /LibreTranslate
|
| 19 |
|
| 20 |
+
# Switch to non-root user
|
| 21 |
+
USER appuser
|
|
|
|
| 22 |
|
| 23 |
+
# Install Python requirements
|
| 24 |
+
RUN pip install --user -r requirements.txt
|
|
|
|
| 25 |
|
| 26 |
+
# Install gunicorn
|
| 27 |
+
RUN pip install --user gunicorn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# Add user's local bin to PATH
|
| 30 |
+
ENV PATH="/home/appuser/.local/bin:${PATH}"
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
# Expose port 5000
|
| 33 |
+
EXPOSE 5000
|
| 34 |
|
| 35 |
+
# Run the application
|
| 36 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app"]
|