File size: 2,475 Bytes
b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d b76891e 747451d | 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
FROM ubuntu:22.04
# Avoid interactive prompts during apt installs (e.g., tzdata).
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
WORKDIR /app
# Install system dependencies and Python 3.12.9
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata ca-certificates && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata && \
apt-get install -y software-properties-common wget build-essential libgl1-mesa-glx libglib2.0-0 git tar && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python3.12 python3.12-dev python3.12-venv && \
wget https://bootstrap.pypa.io/get-pip.py && \
python3.12 get-pip.py && \
rm get-pip.py && \
rm -rf /var/lib/apt/lists/*
# Set python3.12 as default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
ENV PYTHONPATH=/app
ENV GIT_PYTHON_REFRESH=quiet
ENV HUGGINGFACE_HUB_CACHE=/app/hf_cache/hub
ENV MPLCONFIGDIR=/app/mplconfig
# Install Python dependencies
COPY requirements.txt .
# Remove system blinker to avoid pip uninstall error
RUN apt-get update && apt-get remove -y python3-blinker || true
RUN mkdir -p /app/hf_cache/transformers /app/hf_cache/hub /app/mplconfig \
&& chmod -R a+rwx /app/hf_cache /app/mplconfig
# Keep pip tooling current (helps with resolver / wheel selection)
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel
# Install remaining Python dependencies
RUN python -m pip install --no-cache-dir -r requirements.txt
RUN python -m pip install --no-cache-dir transformers accelerate safetensors sentencepiece
# Sanity check: fail build early if a dependency is missing
RUN python -c "import torch, timm; print('torch', torch.__version__); print('timm', timm.__version__)"
# Copy all project files into /app
COPY . .
# Téléchargement et extraction du dataset flowers
RUN mkdir -p image_classification/datasets && \
wget http://download.tensorflow.org/example_images/flower_photos.tgz -O image_classification/datasets/flower_photos.tgz && \
tar --no-same-owner -xf image_classification/datasets/flower_photos.tgz -C image_classification/datasets && \
rm image_classification/datasets/flower_photos.tgz && \
chmod -R a+rX image_classification/datasets/flower_photos
# Donne les droits d'écriture à tout /app
RUN chmod -R a+rwx /app
EXPOSE 7860
CMD ["python", "app.py"]
|