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