50 lines
1.3 KiB
Text
50 lines
1.3 KiB
Text
FROM rocm/dev-ubuntu-22.04:latest
|
|
|
|
# Set non-interactive frontend
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Install Python and other dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
python3.10 \
|
|
python3-pip \
|
|
python3-venv \
|
|
libsndfile1 \
|
|
ffmpeg \
|
|
portaudio19-dev \
|
|
libjpeg-dev \
|
|
python3-dev \
|
|
&& apt-get install python3-wheel python3-setuptools \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user and set up directories
|
|
RUN useradd -m -u 1001 appuser && \
|
|
mkdir -p /app/outputs /app && \
|
|
chown -R appuser:appuser /app
|
|
|
|
USER appuser
|
|
WORKDIR /app
|
|
|
|
# Copy dependency files
|
|
COPY --chown=appuser:appuser requirements.txt ./requirements.txt
|
|
|
|
# Create and activate virtual environment
|
|
RUN python3 -m venv /app/venv
|
|
ENV PATH="/app/venv/bin:$PATH"
|
|
|
|
# Install PyTorch with ROCm support and other dependencies
|
|
RUN pip3 install --no-cache-dir --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.4/ && \
|
|
pip3 install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy project files
|
|
COPY --chown=appuser:appuser . .
|
|
|
|
# Set environment variables
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONPATH=/app \
|
|
USE_GPU=true
|
|
|
|
# Expose the port
|
|
EXPOSE 5005
|
|
|
|
# Run FastAPI server with uvicorn
|
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "5005", "--workers", "1"]
|