File size: 1,648 Bytes
b3a031d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
ARG PYTHON_VERSION=3.9
# Download LFS content while building in order to make this step cacheable
#===== LFS =====
FROM alpine/git:2.36.2 AS lfs
WORKDIR /app

FROM python:${PYTHON_VERSION}
ENV DEBIAN_FRONTEND=noninteractive \
	TZ=Europe/Paris

# BEGIN Static Part
RUN apt-get update && apt-get install -y \
	git \
	git-lfs \
	ffmpeg \
	libsm6 \
	libxext6 \
	cmake \
	libgl1-mesa-glx \
	&& rm -rf /var/lib/apt/lists/* \
	&& git lfs install

# User
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH
WORKDIR /home/user/app

ARG PIP_VERSION=22.3.1
RUN pip install --no-cache-dir pip==${PIP_VERSION} && \
    pip install --no-cache-dir \
        datasets \
        "huggingface-hub>=0.12.1" "protobuf<4" "click<8.1" "pydantic~=1.0"

#^ Waiting for https://github.com/huggingface/huggingface_hub/pull/1345/files to be merge

# END Static Part

# BEGIN Dynamic Part
USER root
# User Debian packages


USER user

# Pre requirements (e.g. upgrading pip)
RUN --mount=target=pre-requirements.txt,source=pre-requirements.txt \
	pip install --no-cache-dir -r pre-requirements.txt

# Python packages
RUN --mount=target=requirements.txt,source=requirements.txt \
	pip install --no-cache-dir -r requirements.txt

# Streamlit and Gradio
ARG SDK= \
	SDK_VERSION=
RUN pip install --no-cache-dir \
        ${SDK}==${SDK_VERSION}

# App
COPY --link --chown=1000 --from=lfs /app /home/user/app
COPY --link --chown=1000 ./ /home/user/app
ENV PYTHONPATH=$HOME/app \
	PYTHONUNBUFFERED=1 \
	GRADIO_ALLOW_FLAGGING=never \
	GRADIO_NUM_PORTS=1 \
	GRADIO_SERVER_NAME=0.0.0.0 \
	GRADIO_THEME=huggingface \
	SYSTEM=spaces

#END Dynamic