|
|
| FROM ubuntu:22.04 |
|
|
| |
| ARG DEBIAN_FRONTEND=noninteractive |
| ENV TZ=Etc/UTC |
|
|
| WORKDIR /app |
|
|
| |
| 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/* |
| |
| 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 |
|
|
|
|
| |
| COPY requirements.txt . |
|
|
| |
| 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 |
|
|
| |
| RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel |
|
|
| |
| RUN python -m pip install --no-cache-dir -r requirements.txt |
| RUN python -m pip install --no-cache-dir transformers accelerate safetensors sentencepiece |
|
|
| |
| RUN python -c "import torch, timm; print('torch', torch.__version__); print('timm', timm.__version__)" |
|
|
| |
| COPY . . |
| |
| |
| 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 |
|
|
| |
| RUN chmod -R a+rwx /app |
|
|
| EXPOSE 7860 |
|
|
| CMD ["python", "app.py"] |
|
|
|
|