Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +13 -19
Dockerfile
CHANGED
@@ -1,31 +1,25 @@
|
|
1 |
-
#
|
2 |
-
FROM python:3.
|
3 |
|
4 |
# Set working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
#
|
8 |
-
RUN mkdir -p /app/cache && chmod -R 777 /app/cache
|
9 |
-
|
10 |
-
# Bersihkan cache lama (untuk mencegah error izin)
|
11 |
-
RUN rm -rf /app/cache/* && chmod -R 777 /app/cache
|
12 |
-
|
13 |
-
# Upgrade pip untuk kompatibilitas paket terbaru
|
14 |
-
RUN pip install --upgrade pip
|
15 |
-
|
16 |
-
# Salin requirements.txt dan install dependensi
|
17 |
COPY requirements.txt .
|
|
|
|
|
18 |
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
|
20 |
-
#
|
21 |
-
COPY
|
22 |
|
23 |
-
#
|
24 |
ENV HF_HOME=/app/cache
|
25 |
ENV TRANSFORMERS_CACHE=/app/cache
|
|
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
|
30 |
-
#
|
31 |
-
CMD ["uvicorn", "
|
|
|
1 |
+
# Use a lightweight Python base image
|
2 |
+
FROM python:3.10-slim
|
3 |
|
4 |
# Set working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Copy requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
COPY requirements.txt .
|
9 |
+
|
10 |
+
# Install dependencies
|
11 |
RUN pip install --no-cache-dir -r requirements.txt
|
12 |
|
13 |
+
# Copy application code
|
14 |
+
COPY . .
|
15 |
|
16 |
+
# Set environment variables for Hugging Face cache
|
17 |
ENV HF_HOME=/app/cache
|
18 |
ENV TRANSFORMERS_CACHE=/app/cache
|
19 |
+
ENV USE_QUANTIZATION=0 # Set to 1 if using quantization and GPU is available
|
20 |
|
21 |
+
# Expose port for FastAPI
|
22 |
+
EXPOSE 8000
|
23 |
|
24 |
+
# Run the FastAPI app with uvicorn
|
25 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|