Spaces:
Sleeping
Sleeping
| # Base image | |
| FROM python:3.11-slim-bullseye AS final | |
| # Use bash as default shell | |
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | |
| # Install dependencies | |
| RUN apt-get update && apt-get install -y curl bash git && rm -rf /var/lib/apt/lists/* | |
| # Set environment variables for NVM | |
| ENV NVM_DIR="/home/user/.nvm" | |
| ENV PATH="${NVM_DIR}/versions/node/$(ls ${NVM_DIR}/versions/node)/bin:$PATH" | |
| # Create NVM directory and install NVM | |
| RUN mkdir -p $NVM_DIR && \ | |
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash | |
| # Persist NVM configuration | |
| RUN echo 'export NVM_DIR="$HOME/.nvm"' >> /etc/profile.d/nvm.sh && \ | |
| echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' >> /etc/profile.d/nvm.sh && \ | |
| echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"' >> /etc/profile.d/nvm.sh | |
| # Install Node.js using NVM | |
| RUN bash -c "source $NVM_DIR/nvm.sh && nvm install --lts && nvm use --lts && node -v && npm -v" | |
| # Set working directory | |
| WORKDIR /app | |
| COPY . /app | |
| # Ensure Node.js dependencies (including dotenv) are installed | |
| RUN bash -c "source $NVM_DIR/nvm.sh && npm install" | |
| # Install Python dependencies (including Uvicorn) | |
| RUN pip install --no-cache-dir --upgrade pip && pip install uvicorn fastapi | |
| # Expose ports | |
| EXPOSE 7860 | |
| # Run both Node.js & Python servers | |
| CMD ["/bin/bash", "-c", "source $NVM_DIR/nvm.sh && node server.js"] | |