Spaces:
Running
Running
| FROM calciumion/new-api:latest | |
| # 1. Install Python and Pip cleanly | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 \ | |
| python3-pip \ | |
| && pip3 install huggingface_hub --break-system-packages \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| EXPOSE 3000 | |
| ENV PORT=7860 | |
| # 2. Start the API and the backup loop | |
| # This loop waits 24 hours (86400s), then uploads the log file to your private dataset | |
| CMD ["/bin/sh", "-c", "/app/new-api & while true; do \ | |
| sleep 86400; \ | |
| python3 -c \"from huggingface_hub import HfApi; import os; \ | |
| api=HfApi(); \ | |
| api.upload_file( \ | |
| path_or_fileobj='/app/new-api.log', \ | |
| path_in_repo='daily_backup.log', \ | |
| repo_id='Dinnerbone5443/my-api-backup', \ | |
| repo_type='dataset', \ | |
| token=os.environ.get('HF_TOKEN') \ | |
| )\"; \ | |
| done"] | |