Spaces:
Sleeping
Sleeping
| # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | |
| # you will also find guides on how best to write your Dockerfile | |
| # Use an official Node runtime as a parent image | |
| FROM node:16 as node-builder | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Copy package.json and package-lock.json | |
| COPY package*.json ./ | |
| # Install dependencies | |
| RUN npm install | |
| # Copy the rest of the application code | |
| COPY . . | |
| # Build the React app | |
| RUN npm run build | |
| # Use an official Python runtime as a parent image | |
| FROM python:3.9 | |
| # Create a new user | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Copy the built React app from the node-builder stage | |
| COPY --from=node-builder /app/build /app/build | |
| # Copy requirements.txt and install Python dependencies | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY --chown=user . /app | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |