Update Dockerfile
Browse files- Dockerfile +38 -26
Dockerfile
CHANGED
|
@@ -1,31 +1,43 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
RUN pip3 install --upgrade pip && pip3 install -r requirements.txt
|
| 11 |
-
|
| 12 |
-
ENTRYPOINT pip3 install -r requirements.txt && python3 -Xfrozen_modules=off .
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
FROM python:3.10 as rvc-api
|
| 16 |
-
|
| 17 |
-
WORKDIR /app
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
COPY rvc_models/ ./rvc_models
|
| 21 |
-
|
| 22 |
-
RUN pip3 install rvc-python && \
|
| 23 |
-
pip3 install torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118 && \
|
| 24 |
-
pip3 install tensorboardX
|
| 25 |
-
|
| 26 |
-
ENTRYPOINT [ "python3","-m","rvc_python","api","-l" ]
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
|
|
|
|
|
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
|
|
|
|
|
|
|
|
| 1 |
+
ARG PYTHON_VERSION=3.12.1
|
| 2 |
+
FROM python:${PYTHON_VERSION}-slim AS base
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && \
|
| 6 |
+
apt-get install -y pipenv && \
|
| 7 |
+
apt-get install -y \
|
| 8 |
+
fontconfig \
|
| 9 |
+
fonts-dejavu \
|
| 10 |
+
fonts-dejavu-core \
|
| 11 |
+
fonts-dejavu-extra \
|
| 12 |
+
fonts-liberation \
|
| 13 |
+
fonts-noto \
|
| 14 |
+
git \
|
| 15 |
+
ffmpeg && \
|
| 16 |
+
rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
# Set environment variables
|
| 19 |
+
ENV PORT=7860
|
| 20 |
+
ENV PIPENV_VENV_IN_PROJECT=1
|
| 21 |
+
|
| 22 |
+
# Create a non-root user and group
|
| 23 |
+
RUN groupadd -g 1000 appuser && \
|
| 24 |
+
useradd -m -u 1000 -g appuser appuser
|
| 25 |
+
|
| 26 |
+
# Set the working directory and adjust permissions
|
| 27 |
WORKDIR /app
|
| 28 |
+
RUN chown -R appuser:appuser /app
|
| 29 |
|
| 30 |
+
# Switch to the non-root user
|
| 31 |
+
USER appuser
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
# Copy application code
|
| 34 |
+
COPY --chown=appuser:appuser . .
|
| 35 |
|
| 36 |
+
# Install dependencies (inside the virtual environment created by Pipenv)
|
| 37 |
+
RUN pipenv install --dev --ignore-pipfile && \
|
| 38 |
+
pipenv run pip install fastapi asyncio uvicorn mutagen requests imageio[ffmpeg] imageio[pyav] assemblyai moviepy git+https://github.com/yt-dlp/yt-dlp
|
| 39 |
+
# Expose the application port
|
| 40 |
+
EXPOSE 7860
|
| 41 |
|
| 42 |
+
# Command to run the application
|
| 43 |
+
CMD ["pipenv", "run", "python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "8", "--timeout-keep-alive", "600"]
|