Spaces:
Running
Running
| FROM ubuntu:22.04 AS root | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| TZ=Europe/Paris | |
| RUN apt-get update && apt-get install -y fakeroot wget gnupg && \ | |
| mv /usr/bin/apt-get /usr/bin/.apt-get && \ | |
| echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \ | |
| chmod +x /usr/bin/apt-get && \ | |
| rm -rf /var/lib/apt/lists/* && \ | |
| useradd -m -u 1000 user | |
| FROM scratch AS base | |
| COPY --chown=1000:1000 --from=root / / | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| DEBIAN_FRONTEND=noninteractive \ | |
| TZ=Europe/Paris | |
| WORKDIR /home/user/app | |
| # Neuron setup | |
| ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/aws/neuron/lib | |
| # AWS Neuron GPG Key | |
| RUN wget -qO /tmp/neuron.asc https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB && \ | |
| gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --import /tmp/neuron.asc && \ | |
| gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --export --output /etc/apt/trusted.gpg.d/neuron.gpg && \ | |
| echo "deb https://apt.repos.neuron.amazonaws.com jammy main" > /etc/apt/sources.list.d/neuron.list | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| git-lfs \ | |
| ffmpeg \ | |
| libsm6 \ | |
| libxext6 \ | |
| cmake \ | |
| rsync \ | |
| libgl1 \ | |
| aws-neuronx-tools \ | |
| aws-neuronx-collectives \ | |
| aws-neuronx-runtime-lib \ | |
| pip \ | |
| socat \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && git lfs install | |
| ENV PATH =/opt/aws/neuron/bin:$PATH | |
| ARG OPTIMUM_NEURON_BRANCH=main | |
| RUN git clone --branch $OPTIMUM_NEURON_BRANCH https://github.com/huggingface/optimum-neuron.git /tmp/optimum-neuron && \ | |
| pip install --no-cache-dir "/tmp/optimum-neuron[neuronx]" && \ | |
| rm -rf /tmp/optimum-neuron | |
| # End Neuron setup | |
| RUN pip install --no-cache-dir pip -U && \ | |
| pip install --no-cache-dir \ | |
| datasets \ | |
| "huggingface-hub>=0.19" "hf_xet>=1.0.0,<2.0.0" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0" | |
| RUN \ | |
| apt-get update && \ | |
| apt-get install -y curl && \ | |
| curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ | |
| apt-get install -y nodejs && \ | |
| rm -rf /var/lib/apt/lists/* && apt-get clean | |
| # Python packages | |
| RUN --mount=target=/tmp/requirements.txt,source=requirements.txt \ | |
| pip install --no-cache-dir -r /tmp/requirements.txt | |
| # Streamlit and Gradio | |
| RUN pip install --no-cache-dir \ | |
| gradio[oauth,mcp]==5.31.0 \ | |
| "uvicorn>=0.14.0" \ | |
| spaces | |
| ENTRYPOINT ["python3", "./app.py"] | |
| FROM base AS pipfreeze | |
| RUN pip freeze > /tmp/freeze.txt | |
| FROM base AS run | |
| COPY --link --chown=1000 ./ /home/user/app | |
| # Warning, if you change something under this line, dont forget to change the PIP_FREEZE_REVERSED_INDEX | |
| COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt | |
| ENV PYTHONPATH=$HOME/app \ | |
| PYTHONUNBUFFERED=1 \ | |
| HF_HUB_ENABLE_HF_TRANSFER=1 \ | |
| GRADIO_ALLOW_FLAGGING=never \ | |
| GRADIO_FLAGGING_MODE=never \ | |
| GRADIO_CACHE_EXAMPLES=true \ | |
| GRADIO_NUM_PORTS=1 \ | |
| GRADIO_SERVER_NAME=0.0.0.0 \ | |
| GRADIO_SSR_MODE=True \ | |
| GRADIO_THEME=huggingface \ | |
| TQDM_POSITION=-1 \ | |
| TQDM_MININTERVAL=1 \ | |
| SYSTEM=spaces |