Fix the deployment space problem
Browse files- Dockerfile +11 -15
Dockerfile
CHANGED
|
@@ -1,36 +1,32 @@
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
-
# Create user
|
| 4 |
RUN useradd -m -u 1000 user
|
| 5 |
-
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
-
#
|
| 9 |
COPY requirements.txt .
|
| 10 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 11 |
RUN pip install fastapi uvicorn python-multipart requests
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
COPY
|
| 15 |
-
COPY scripts/ ./scripts/
|
| 16 |
-
COPY checkpoints/ ./checkpoints/
|
| 17 |
-
COPY data/ ./data/
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
RUN mkdir -p ui
|
| 24 |
COPY ui/ ./ui/
|
| 25 |
|
| 26 |
-
# Optional cache-buster
|
| 27 |
RUN echo "UI_BUILD_TS=$(date +%s)" > /app/ui/.buildtag
|
| 28 |
|
| 29 |
-
#
|
| 30 |
RUN chown -R user:user /app
|
| 31 |
USER user
|
| 32 |
-
|
| 33 |
EXPOSE 7860
|
| 34 |
|
| 35 |
-
#
|
| 36 |
CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
| 3 |
+
# --- 1. Create user and working directory ---
|
| 4 |
RUN useradd -m -u 1000 user
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# --- 2. Install dependencies ---
|
| 8 |
COPY requirements.txt .
|
| 9 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 10 |
RUN pip install fastapi uvicorn python-multipart requests
|
| 11 |
|
| 12 |
+
# --- 3. Copy your backend code ---
|
| 13 |
+
COPY --chown=user:user . .
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
# --- 4. Create API directory and copy your app.py into it ---
|
| 16 |
+
RUN mkdir -p api
|
| 17 |
+
COPY app.py api/app.py
|
| 18 |
|
| 19 |
+
# --- 5. Copy UI (last to force rebuild when changed) ---
|
| 20 |
RUN mkdir -p ui
|
| 21 |
COPY ui/ ./ui/
|
| 22 |
|
| 23 |
+
# Optional: small cache-buster to ensure rebuilds update UI
|
| 24 |
RUN echo "UI_BUILD_TS=$(date +%s)" > /app/ui/.buildtag
|
| 25 |
|
| 26 |
+
# --- 6. Permissions and start ---
|
| 27 |
RUN chown -R user:user /app
|
| 28 |
USER user
|
|
|
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
+
# --- 7. Run FastAPI ---
|
| 32 |
CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "7860"]
|