ArabGuard_Normalizer / Dockerfile
3v324v23's picture
Deploy Docker Space with build-time training
f3dcb14
Raw
History Blame Contribute Delete
1.27 kB
FROM python:3.11-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
TOKENIZERS_PARALLELISM=false \
MODEL_OUTPUT_DIR=/app/arabguard_model \
CHECKPOINT_DIR=/tmp/arabguard_checkpoints \
DASHBOARD_DATA_DIR=/app/dashboard_data
WORKDIR /app
COPY requirements.txt ./requirements.txt
RUN pip install --upgrade pip && pip install -r requirements.txt
FROM base AS trainer
# Keep downloads and checkpoints in this disposable build stage.
ENV HF_HOME=/tmp/huggingface
# Only source code is copied from Git. The dataset and base model are downloaded,
# trained, and saved into the image while Hugging Face builds the Space.
COPY train_model.py ./
RUN python train_model.py
FROM base AS runtime
# Copy only the trained artifacts, not the dataset cache or checkpoints.
COPY --from=trainer --chown=1000:1000 /app/arabguard_model ./arabguard_model
COPY --from=trainer --chown=1000:1000 /app/dashboard_data ./dashboard_data
COPY app.py ./
ENV HOME=/home/user \
HF_HOME=/home/user/.cache/huggingface
RUN useradd --create-home --uid 1000 user \
&& chown -R user:user /app
USER user
EXPOSE 7860
CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860", "--server.headless=true"]