srtchecktest / Dockerfile
bigbossmonster's picture
Update Dockerfile
9810c30 verified
# Stage 1: Build the React Frontend
FROM node:18-alpine as build
WORKDIR /app
# Copy package files and install dependencies
COPY package.json vite.config.js ./
# We need to install the dependencies.
# Since I cannot provide the full package-lock.json, we use 'npm install'
# Note: In a real repo, you would copy package-lock.json too.
RUN npm install
# Copy source code
COPY . .
# Build the app (outputs to /app/dist)
RUN npm run dev
# Stage 2: Setup the Python Backend
FROM python:3.9-slim
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy Backend Code
COPY main.py .
# Copy Built Frontend Assets from Stage 1
COPY --from=build /app/dist ./dist
# Create a non-root user for security (Required by HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose the port HF Spaces expects (7860)
EXPOSE 7860
# Run FastAPI
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]