coding-alt/IF
1
1# Download LFS content while building in order to make this step cacheable2# #===== LFS =====3# FROM alpine/git:2.36.2 AS lfs4# WORKDIR /app5# COPY --link .lfs.hf.co .6# RUN --mount=type=secret,id=SPACE_REPOSITORY,mode=0444,required=true \7# git init \8# && git remote add origin $(cat /run/secrets/SPACE_REPOSITORY) \9# && git add --all \10# && git config user.email "name@mail.com" \11# && git config user.name "Name" \12# && git commit -m "lfs" \13# && git lfs pull \14# && rm -rf .git .gitattributes15# #===============16 17FROM nvidia/cuda:11.8.0-runtime-ubuntu18.0418# BEGIN Static part19ENV DEBIAN_FRONTEND=noninteractive \20 TZ=Europe/Paris21 22RUN apt-get update && apt-get install -y \23 git \24 make build-essential libssl-dev zlib1g-dev \25 libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \26 libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git-lfs \27 ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx \28 && rm -rf /var/lib/apt/lists/* \29 && git lfs install30 31# User32RUN useradd -m -u 1000 user33USER user34ENV HOME=/home/user \35 PATH=/home/user/.local/bin:$PATH36WORKDIR /home/user/app37 38# Pyenv39RUN curl https://pyenv.run | bash40ENV PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH41 42ARG PIP_VERSION=22.3.143ARG PYTHON_VERSION=3.1044# Python45RUN pyenv install $PYTHON_VERSION && \46 pyenv global $PYTHON_VERSION && \47 pyenv rehash && \48 pip install --no-cache-dir --upgrade pip==${PIP_VERSION} setuptools wheel && \49 pip install --no-cache-dir \50 datasets \51 "huggingface-hub>=0.12.1" "protobuf<4" "click<8.1"52 53#^ Waiting for https://github.com/huggingface/huggingface_hub/pull/1345/files to be merge54 55USER root56# User Debian packages57## Security warning : Potential user code executed as root (build time)58RUN --mount=target=/root/packages.txt,source=packages.txt \59 apt-get update && \60 xargs -r -a /root/packages.txt apt-get install -y \61 && rm -rf /var/lib/apt/lists/*62 63USER user64 65# Pre requirements (e.g. upgrading pip)66RUN --mount=target=pre-requirements.txt,source=pre-requirements.txt \67 pip install --no-cache-dir -r pre-requirements.txt68 69# Python packages70RUN pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu11771RUN --mount=target=requirements.txt,source=requirements.txt \72 pip install --no-cache-dir -r requirements.txt73 74ARG SDK=gradio \75 SDK_VERSION=3.27.076RUN pip install --no-cache-dir \77 ${SDK}==${SDK_VERSION}78 79# App80# COPY --link --chown=1000 --from=lfs /app /home/user/app81COPY --link --chown=1000 ./ /home/user/app82ENV PYTHONPATH=$HOME/app \83 PYTHONUNBUFFERED=1 \84 GRADIO_ALLOW_FLAGGING=never \85 GRADIO_NUM_PORTS=1 \86 GRADIO_SERVER_NAME=0.0.0.0 \87 GRADIO_THEME=huggingface \88 SYSTEM=spaces89 90CMD ["python", "app.py"]