Update Dockerfile
Browse files- Dockerfile +19 -11
Dockerfile
CHANGED
|
@@ -1,18 +1,26 @@
|
|
| 1 |
-
# Use the official Python 3.
|
| 2 |
FROM python:3.12.6
|
| 3 |
-
USER user
|
| 4 |
-
# Copy the current directory contents into the container at .
|
| 5 |
-
COPY . .
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
# Start the FastAPI app on port 7860
|
| 18 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use the official Python 3.12.6 image
|
| 2 |
FROM python:3.12.6
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# Create a new group and user
|
| 5 |
+
RUN groupadd -r user && useradd -r -g user user
|
| 6 |
+
|
| 7 |
+
# Set environment variable for cache directory
|
| 8 |
+
ENV TRANSFORMERS_CACHE=/app/hf_cache
|
| 9 |
+
|
| 10 |
+
# Create the cache directory and set permissions
|
| 11 |
+
RUN mkdir -p /app/hf_cache && chown -R user:user /app/hf_cache
|
| 12 |
|
| 13 |
+
# Set the working directory
|
| 14 |
+
WORKDIR /app
|
| 15 |
|
| 16 |
+
# Copy the current directory contents into the container at /app
|
| 17 |
+
COPY --chown=user:user . /app
|
| 18 |
|
| 19 |
+
# Install requirements
|
| 20 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 21 |
+
|
| 22 |
+
# Switch to the new user
|
| 23 |
+
USER user
|
| 24 |
|
| 25 |
+
# Start the FastAPI app on port 7860
|
| 26 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|