MIR_Group07 / Dockerfile
RaxoM21's picture
Initial Space deploy: code only, data pulled from Dataset at build
125f72e
Raw History Blame Contribute Delete
1.8 kB
# ─────────────────────────────────────────────────────────────────
# Group 07 β€” I-ILIA-014 MIR Project β€’ Dockerfile (HF Spaces)
#
# Architecture:
# β€’ Data decoupled from Space repo: downloaded from separate Dataset repo
# β€’ Archives extracted at build time into /home/user/app/
# β€’ Port 7860 (HF Spaces default)
# β€’ UID 1000 user "user" (HF Spaces convention)
# β€’ Layer caching: data layer cached across code-only rebuilds
# ─────────────────────────────────────────────────────────────────
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential && rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /home/user/app
# Layer 1: install huggingface_hub to run the download script
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir "huggingface_hub>=0.23"
# Layer 2: download and extract data β€” cached across code-only rebuilds
COPY --chown=user download_data.py .
RUN python download_data.py
# Layer 3: install app dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Layer 4: copy app code β€” only this layer rebuilds on code changes
COPY --chown=user . .
ENV MIR_H5_DIR=/home/user/app/descriptors/CLIP_Flickr8k \
MIR_MAX_BACKBONES=4 \
MIR_DEFAULT_BACKBONE=clip
EXPOSE 7860
CMD ["gunicorn", "--chdir", "/home/user/app/Interface", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "300", "app:app"]