Update Dockerfile
Browse files- Dockerfile +13 -12
Dockerfile
CHANGED
@@ -1,16 +1,14 @@
|
|
1 |
# Use Python base image
|
2 |
FROM python:3.12.2
|
3 |
|
|
|
4 |
RUN useradd -m -u 1000 user
|
5 |
-
USER user
|
6 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
7 |
-
COPY --chown=user . /app/
|
8 |
|
9 |
-
#
|
10 |
ENV DEBIAN_FRONTEND=noninteractive
|
11 |
ENV TZ=UTC
|
12 |
|
13 |
-
# Install system dependencies
|
14 |
RUN apt-get update && apt-get install -y \
|
15 |
ffmpeg \
|
16 |
git \
|
@@ -21,15 +19,19 @@ RUN apt-get update && apt-get install -y \
|
|
21 |
libssl-dev \
|
22 |
&& rm -rf /var/lib/apt/lists/*
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
ENV PATH="/
|
27 |
|
28 |
# Set working directory
|
29 |
WORKDIR /app
|
30 |
|
31 |
-
# Copy application code
|
32 |
-
COPY . /app
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# Install Python dependencies
|
35 |
RUN pip install --no-cache-dir -U pip setuptools wheel
|
@@ -37,7 +39,6 @@ RUN pip install --no-cache-dir setuptools-rust
|
|
37 |
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
38 |
RUN pip install --no-cache-dir -r requirements.txt
|
39 |
|
40 |
-
|
41 |
# Environment variables for PyTorch and Whisper
|
42 |
ENV TORCH_DEVICE="cuda"
|
43 |
ENV FORCE_FP32="false"
|
@@ -46,4 +47,4 @@ ENV FORCE_FP32="false"
|
|
46 |
EXPOSE 7860
|
47 |
|
48 |
# Start the FastAPI application
|
49 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "5"]
|
|
|
1 |
# Use Python base image
|
2 |
FROM python:3.12.2
|
3 |
|
4 |
+
# Add a new user but do not switch yet
|
5 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
6 |
|
7 |
+
# Set non-interactive mode for package installation
|
8 |
ENV DEBIAN_FRONTEND=noninteractive
|
9 |
ENV TZ=UTC
|
10 |
|
11 |
+
# Install system dependencies (RUN as root)
|
12 |
RUN apt-get update && apt-get install -y \
|
13 |
ffmpeg \
|
14 |
git \
|
|
|
19 |
libssl-dev \
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
+
# Switch to non-root user AFTER installing system dependencies
|
23 |
+
USER user
|
24 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
25 |
|
26 |
# Set working directory
|
27 |
WORKDIR /app
|
28 |
|
29 |
+
# Copy application code with correct ownership
|
30 |
+
COPY --chown=user . /app/
|
31 |
+
|
32 |
+
# Install Rust for setuptools-rust
|
33 |
+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
34 |
+
ENV PATH="/home/user/.cargo/bin:${PATH}"
|
35 |
|
36 |
# Install Python dependencies
|
37 |
RUN pip install --no-cache-dir -U pip setuptools wheel
|
|
|
39 |
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
40 |
RUN pip install --no-cache-dir -r requirements.txt
|
41 |
|
|
|
42 |
# Environment variables for PyTorch and Whisper
|
43 |
ENV TORCH_DEVICE="cuda"
|
44 |
ENV FORCE_FP32="false"
|
|
|
47 |
EXPOSE 7860
|
48 |
|
49 |
# Start the FastAPI application
|
50 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "5"]
|