Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +11 -5
Dockerfile
CHANGED
|
@@ -1,11 +1,17 @@
|
|
| 1 |
# 1. Use the official Python 3.10 slim image (matches your version)
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# 2. Set the working directory inside the container
|
| 5 |
-
WORKDIR /app
|
| 6 |
|
| 7 |
# 3. Copy requirements first (This caches the installation layer)
|
| 8 |
-
COPY requirements.txt .
|
| 9 |
|
| 10 |
# 4. Install dependencies
|
| 11 |
# --no-cache-dir keeps the image small
|
|
@@ -13,11 +19,11 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 13 |
|
| 14 |
# 5. Copy the rest of your code
|
| 15 |
# (The .dockerignore file will stop .env from being copied here)
|
| 16 |
-
COPY . .
|
| 17 |
|
| 18 |
# 6. Expose the app port
|
| 19 |
-
EXPOSE
|
| 20 |
|
| 21 |
# 7. Run the application
|
| 22 |
# Use fastapi_app:app (not main:app) and honor Cloud Run PORT if provided
|
| 23 |
-
CMD ["
|
|
|
|
| 1 |
# 1. Use the official Python 3.10 slim image (matches your version)
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
RUN useradd -m -u 1000 user
|
| 5 |
+
USER user
|
| 6 |
+
ENV HOME=/home/user \
|
| 7 |
+
PATH=/home/user/.local/bin:$PATH
|
| 8 |
+
|
| 9 |
+
|
| 10 |
# 2. Set the working directory inside the container
|
| 11 |
+
WORKDIR $HOME/app
|
| 12 |
|
| 13 |
# 3. Copy requirements first (This caches the installation layer)
|
| 14 |
+
COPY --chown=user requirements.txt .
|
| 15 |
|
| 16 |
# 4. Install dependencies
|
| 17 |
# --no-cache-dir keeps the image small
|
|
|
|
| 19 |
|
| 20 |
# 5. Copy the rest of your code
|
| 21 |
# (The .dockerignore file will stop .env from being copied here)
|
| 22 |
+
COPY --chown=user . .
|
| 23 |
|
| 24 |
# 6. Expose the app port
|
| 25 |
+
EXPOSE 7860
|
| 26 |
|
| 27 |
# 7. Run the application
|
| 28 |
# Use fastapi_app:app (not main:app) and honor Cloud Run PORT if provided
|
| 29 |
+
CMD ["uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "7860"]
|