srtchecker / Dockerfile
bigbossmonster's picture
Update Dockerfile
323e51f verified
FROM python:3.12
WORKDIR /app
# 1. Install Git
RUN apt-get update && apt-get install -y git
# 2. Install dependencies from your PUBLIC repo (if you have one there) #
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 3. Clone the Private Repository
ARG CACHE_BUST=1
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
export HF_TOKEN=$(cat /run/secrets/HF_TOKEN) && \
git clone https://bigbossmonster:${HF_TOKEN}@huggingface.co/spaces/bigbossmonster/srtcheckrepo /app/private_code
# 4. Try to install private requirements ONLY if the file exists
# This 'if' statement prevents the build from crashing if the file is missing #
RUN if [ -f /app/private_code/requirements.txt ]; then \
pip install --no-cache-dir -r /app/private_code/requirements.txt; \
fi
# 5. Setup User
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# 6. Run the app from the private folder
WORKDIR /app/private_code
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]