Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +23 -18
Dockerfile
CHANGED
@@ -1,38 +1,43 @@
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
#
|
|
|
|
|
|
|
4 |
RUN apt-get update && apt-get install -y \
|
5 |
espeak-ng \
|
6 |
git \
|
7 |
libsndfile1 \
|
8 |
curl
|
9 |
|
10 |
-
#
|
11 |
ENV PYTHONUNBUFFERED=1 \
|
12 |
-
HF_HOME=/
|
13 |
PYTHONPATH="/app"
|
14 |
|
15 |
-
#
|
16 |
-
RUN mkdir -p /app/cache && \
|
17 |
-
|
|
|
18 |
|
19 |
WORKDIR /app
|
20 |
|
21 |
-
#
|
22 |
COPY requirements.txt .
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
#
|
28 |
-
RUN pip install
|
|
|
29 |
|
30 |
-
#
|
31 |
-
RUN
|
32 |
-
chmod -R 777 /.config
|
33 |
|
34 |
-
#
|
35 |
-
COPY . .
|
36 |
|
37 |
-
#
|
38 |
-
CMD uvicorn app:app --host 0.0.0.0 --port 7860
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
+
# Create a non-root user
|
4 |
+
RUN useradd -m -u 1000 appuser
|
5 |
+
|
6 |
+
# Install system dependencies
|
7 |
RUN apt-get update && apt-get install -y \
|
8 |
espeak-ng \
|
9 |
git \
|
10 |
libsndfile1 \
|
11 |
curl
|
12 |
|
13 |
+
# Configure environment
|
14 |
ENV PYTHONUNBUFFERED=1 \
|
15 |
+
HF_HOME=/home/appuser/cache \
|
16 |
PYTHONPATH="/app"
|
17 |
|
18 |
+
# Create necessary directories and set permissions
|
19 |
+
RUN mkdir -p /app /home/appuser/cache /home/appuser/.local /home/appuser/.config/pulse && \
|
20 |
+
chown -R appuser:appuser /app /home/appuser/cache /home/appuser/.local /home/appuser/.config && \
|
21 |
+
chmod -R 755 /app /home/appuser/cache /home/appuser/.local /home/appuser/.config
|
22 |
|
23 |
WORKDIR /app
|
24 |
|
25 |
+
# Copy requirements first for better caching
|
26 |
COPY requirements.txt .
|
27 |
+
RUN chown appuser:appuser requirements.txt
|
28 |
|
29 |
+
# Switch to non-root user
|
30 |
+
USER appuser
|
31 |
|
32 |
+
# Install Python dependencies
|
33 |
+
RUN pip install --user --upgrade pip setuptools wheel && \
|
34 |
+
pip install --user --no-cache-dir -r requirements.txt
|
35 |
|
36 |
+
# Install misaki from source (with data files)
|
37 |
+
RUN pip install --user git+https://github.com/hexgrad/misaki.git --no-cache-dir
|
|
|
38 |
|
39 |
+
# Copy application code
|
40 |
+
COPY --chown=appuser:appuser . .
|
41 |
|
42 |
+
# Run FastAPI
|
43 |
+
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|