Create Dockerfile
Browse files- Dockerfile +34 -0
Dockerfile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Stage 1: Build the React Application
|
| 2 |
+
FROM node:18-alpine AS frontend-builder
|
| 3 |
+
WORKDIR /app/frontend
|
| 4 |
+
COPY frontend/package*.json ./
|
| 5 |
+
RUN npm install
|
| 6 |
+
COPY frontend/ .
|
| 7 |
+
RUN npm run build
|
| 8 |
+
|
| 9 |
+
# Stage 2: Serve with FastAPI
|
| 10 |
+
FROM python:3.10-slim
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# Install backend dependencies
|
| 14 |
+
COPY backend/requirements.txt .
|
| 15 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
+
|
| 17 |
+
# Copy Python backend code
|
| 18 |
+
COPY backend/ /app/backend/
|
| 19 |
+
|
| 20 |
+
# Copy the compiled React files from Stage 1 into the Python container
|
| 21 |
+
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
|
| 22 |
+
|
| 23 |
+
# Mandatory Hugging Face Docker Space Permissions
|
| 24 |
+
RUN useradd -m -u 1000 user
|
| 25 |
+
USER user
|
| 26 |
+
ENV HOME=/home/user \
|
| 27 |
+
PATH=/home/user/.local/bin:$PATH
|
| 28 |
+
WORKDIR $HOME/app
|
| 29 |
+
|
| 30 |
+
COPY --chown=user . $HOME/app
|
| 31 |
+
|
| 32 |
+
# Start the application on the required port
|
| 33 |
+
EXPOSE 7860
|
| 34 |
+
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
|