FROM python:3.10 # Install dependencies and Node.js RUN apt-get update && apt-get install -y \ curl \ git \ ssh \ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y nodejs \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Configure SSH to recognize the host RUN mkdir -p /root/.ssh && ssh-keyscan hf.co >> /root/.ssh/known_hosts # Use the secret SSH key RUN --mount=type=secret,id=SSH_PRIVATE_KEY,mode=0444,required=true \ echo "$(cat /run/secrets/SSH_PRIVATE_KEY)" > /root/.ssh/id_ed25519 && \ chmod 600 /root/.ssh/id_ed25519 # Install Node.js dependencies COPY package.json /app/package.json RUN npm install # Copy Tailwind configuration and static files COPY tailwind.config.js /app/tailwind.config.js COPY templates /app/templates COPY static /app/static # Run the Tailwind CSS build script RUN npm run publish # Git configuration RUN git config --global user.name "nexus3rd" RUN git config --global user.email "problemsolved1990@proton.me" # Clone the repository and conditionally commit and push changes RUN git clone git@hf.co:spaces/nexus4rd/README /app/repo \ && cp /app/templates/output.css /app/repo/templates/output.css \ && cd /app/repo \ && git add templates/output.css \ && if ! git diff --cached --quiet; then \ git commit -m "output.css" && git push -f; \ else \ echo "No changes to commit"; \ fi # Create a user for running the application RUN useradd -m -u 1000 user # Ensure the cookies directory exists and is writable by the user RUN mkdir -p /app/cookies && \ chown -R user:user /app/cookies # Switch to the newly created user USER user ENV PATH="/home/user/.local/bin:$PATH" # Copy and install Python dependencies COPY --chown=user: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:user . . EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]