Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +11 -7
Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
# 1. Use Python 3.
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# 2. Set up the user FIRST (Security requirement)
|
| 5 |
RUN useradd -m -u 1000 user
|
|
@@ -11,16 +11,20 @@ WORKDIR /code
|
|
| 11 |
COPY --chown=user ./requirements.txt /code/requirements.txt
|
| 12 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 13 |
|
| 14 |
-
# 5. COPY EVERYTHING
|
| 15 |
-
# This
|
| 16 |
COPY --chown=user . /code
|
| 17 |
|
| 18 |
-
# 6.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
USER user
|
| 20 |
|
| 21 |
-
#
|
| 22 |
ENV HOME=/home/user \
|
| 23 |
PATH=/home/user/.local/bin:$PATH
|
| 24 |
|
| 25 |
-
#
|
| 26 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# 1. Use Python 3.9
|
| 2 |
+
FROM python:3.9
|
| 3 |
|
| 4 |
# 2. Set up the user FIRST (Security requirement)
|
| 5 |
RUN useradd -m -u 1000 user
|
|
|
|
| 11 |
COPY --chown=user ./requirements.txt /code/requirements.txt
|
| 12 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 13 |
|
| 14 |
+
# 5. COPY EVERYTHING with Ownership Fix
|
| 15 |
+
# This tells Docker: "Make 'user' the owner of all these files, not Root"
|
| 16 |
COPY --chown=user . /code
|
| 17 |
|
| 18 |
+
# 6. FORCE PERMISSIONS (The Fix for Error 13)
|
| 19 |
+
# This grants Read/Write access to the folder so SQLite can create lock files
|
| 20 |
+
RUN chmod -R 777 /code
|
| 21 |
+
|
| 22 |
+
# 7. Switch to the non-root user
|
| 23 |
USER user
|
| 24 |
|
| 25 |
+
# 8. Set Environment Variables
|
| 26 |
ENV HOME=/home/user \
|
| 27 |
PATH=/home/user/.local/bin:$PATH
|
| 28 |
|
| 29 |
+
# 9. Run the App
|
| 30 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|