B
File size: 968 Bytes
eb132f9
 
 
 
 
 
 
 
 
7c69e73
 
eb132f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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"]