badaoui HF Staff commited on
Commit
9e4cf78
·
verified ·
1 Parent(s): 50ffb54

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +80 -64
Dockerfile CHANGED
@@ -1,92 +1,108 @@
1
  FROM ubuntu:22.04 AS root
2
  ENV DEBIAN_FRONTEND=noninteractive \
3
- TZ=Europe/Paris
4
- RUN apt-get update && apt-get install -y fakeroot wget gnupg && \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  mv /usr/bin/apt-get /usr/bin/.apt-get && \
6
  echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \
7
  chmod +x /usr/bin/apt-get && \
8
- rm -rf /var/lib/apt/lists/* && \
9
- useradd -m -u 1000 user
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  FROM scratch AS base
12
  COPY --chown=1000:1000 --from=root / /
 
13
  USER user
14
  ENV HOME=/home/user \
15
- PATH=/home/user/.local/bin:$PATH \
16
- DEBIAN_FRONTEND=noninteractive \
17
- TZ=Europe/Paris
 
 
18
  WORKDIR /home/user/app
19
- # Neuron setup
20
- ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/aws/neuron/lib
21
- # AWS Neuron GPG Key
22
- RUN wget -qO /tmp/neuron.asc https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB && \
23
- gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --import /tmp/neuron.asc && \
24
- gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --export --output /etc/apt/trusted.gpg.d/neuron.gpg && \
25
- echo "deb https://apt.repos.neuron.amazonaws.com jammy main" > /etc/apt/sources.list.d/neuron.list
26
 
27
- RUN apt-get update && apt-get install -y \
28
- git \
29
- git-lfs \
30
- ffmpeg \
31
- libsm6 \
32
- libxext6 \
33
- cmake \
34
- rsync \
35
- libgl1 \
36
- aws-neuronx-tools \
37
- aws-neuronx-collectives \
38
- aws-neuronx-runtime-lib \
39
- pip \
40
- socat \
41
- && rm -rf /var/lib/apt/lists/* \
42
- && git lfs install
43
-
44
- ENV PATH =/opt/aws/neuron/bin:$PATH
45
-
46
- # Install cpu pytorch to avoid having to install cuda deps: it makes image leaner and builds faster
47
- RUN pip install torch==2.8.0 torchvision~=0.23 --index-url https://download.pytorch.org/whl/cpu
48
  # Install optimum-neuron
49
  ARG OPTIMUM_NEURON_VERSION=0.4.1
50
  RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com --no-cache-dir optimum-neuron[neuronx]==$OPTIMUM_NEURON_VERSION
51
- # End Neuron setup
52
- RUN pip install --no-cache-dir pip -U && \
53
- pip install --no-cache-dir \
54
- datasets \
55
- "huggingface-hub>=0.31.4" "protobuf<4" "click<8.1" "pydantic~=1.0"
56
- RUN \
57
- apt-get update && \
58
- apt-get install -y curl && \
59
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
60
- apt-get install -y nodejs && \
61
- rm -rf /var/lib/apt/lists/* && apt-get clean
62
- # Python packages
63
  RUN --mount=target=/tmp/requirements.txt,source=requirements.txt \
64
  pip install --no-cache-dir -r /tmp/requirements.txt
65
 
66
- # Streamlit and Gradio
67
  RUN pip install --no-cache-dir \
68
- gradio[oauth,mcp]==5.31.0 \
69
- "uvicorn>=0.14.0" \
70
- spaces
71
 
72
  ENTRYPOINT ["python3", "./app.py"]
73
 
74
  FROM base AS pipfreeze
75
  RUN pip freeze > /tmp/freeze.txt
 
76
  FROM base AS run
77
  COPY --link --chown=1000 ./ /home/user/app
78
- # Warning, if you change something under this line, dont forget to change the PIP_FREEZE_REVERSED_INDEX
79
  COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt
 
80
  ENV PYTHONPATH=$HOME/app \
81
- PYTHONUNBUFFERED=1 \
82
- HF_XET_HIGH_PERFORMANCE=1 \
83
- GRADIO_ALLOW_FLAGGING=never \
84
- GRADIO_FLAGGING_MODE=never \
85
- GRADIO_CACHE_EXAMPLES=true \
86
- GRADIO_NUM_PORTS=1 \
87
- GRADIO_SERVER_NAME=0.0.0.0 \
88
- GRADIO_SSR_MODE=True \
89
- GRADIO_THEME=huggingface \
90
- TQDM_POSITION=-1 \
91
- TQDM_MININTERVAL=1 \
92
- SYSTEM=spaces
 
1
  FROM ubuntu:22.04 AS root
2
  ENV DEBIAN_FRONTEND=noninteractive \
3
+ TZ=Europe/Paris
4
+
5
+ RUN apt-get update && apt-get install -y \
6
+ fakeroot \
7
+ wget \
8
+ gnupg \
9
+ git \
10
+ git-lfs \
11
+ ffmpeg \
12
+ libsm6 \
13
+ libxext6 \
14
+ cmake \
15
+ rsync \
16
+ libgl1 \
17
+ pip \
18
+ socat \
19
+ curl && \
20
  mv /usr/bin/apt-get /usr/bin/.apt-get && \
21
  echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \
22
  chmod +x /usr/bin/apt-get && \
23
+ git lfs install && \
24
+ rm -rf /var/lib/apt/lists/*
25
+
26
+ # AWS Neuron GPG Key and repository setup (as root)
27
+ RUN wget -qO /tmp/neuron.asc https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB && \
28
+ gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --import /tmp/neuron.asc && \
29
+ gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --export --output /etc/apt/trusted.gpg.d/neuron.gpg && \
30
+ echo "deb https://apt.repos.neuron.amazonaws.com jammy main" > /etc/apt/sources.list.d/neuron.list && \
31
+ rm /tmp/neuron.asc /tmp/temp-keyring.gpg*
32
+
33
+ # Install AWS Neuron packages (as root)
34
+ RUN apt-get update && apt-get install -y \
35
+ aws-neuronx-tools \
36
+ aws-neuronx-collectives \
37
+ aws-neuronx-runtime-lib && \
38
+ rm -rf /var/lib/apt/lists/*
39
+
40
+ # Install Node.js (as root)
41
+ RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
42
+ apt-get install -y nodejs && \
43
+ rm -rf /var/lib/apt/lists/* && \
44
+ apt-get clean
45
+
46
+ # Create user
47
+ RUN useradd -m -u 1000 user
48
 
49
  FROM scratch AS base
50
  COPY --chown=1000:1000 --from=root / /
51
+
52
  USER user
53
  ENV HOME=/home/user \
54
+ PATH=/home/user/.local/bin:/opt/aws/neuron/bin:$PATH \
55
+ DEBIAN_FRONTEND=noninteractive \
56
+ TZ=Europe/Paris \
57
+ LD_LIBRARY_PATH=/opt/aws/neuron/lib:$LD_LIBRARY_PATH
58
+
59
  WORKDIR /home/user/app
 
 
 
 
 
 
 
60
 
61
+ # Install Python packages as user
62
+ RUN pip install --no-cache-dir pip -U && \
63
+ pip install torch==2.8.0 torchvision~=0.23 --index-url https://download.pytorch.org/whl/cpu
64
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  # Install optimum-neuron
66
  ARG OPTIMUM_NEURON_VERSION=0.4.1
67
  RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com --no-cache-dir optimum-neuron[neuronx]==$OPTIMUM_NEURON_VERSION
68
+
69
+ # Install base Python packages
70
+ RUN pip install --no-cache-dir \
71
+ datasets \
72
+ "huggingface-hub>=0.31.4" \
73
+ "protobuf<4" \
74
+ "click<8.1" \
75
+ "pydantic~=1.0"
76
+
77
+ # Install requirements from file
 
 
78
  RUN --mount=target=/tmp/requirements.txt,source=requirements.txt \
79
  pip install --no-cache-dir -r /tmp/requirements.txt
80
 
81
+ # Install Streamlit and Gradio
82
  RUN pip install --no-cache-dir \
83
+ gradio[oauth,mcp]==5.31.0 \
84
+ "uvicorn>=0.14.0" \
85
+ spaces
86
 
87
  ENTRYPOINT ["python3", "./app.py"]
88
 
89
  FROM base AS pipfreeze
90
  RUN pip freeze > /tmp/freeze.txt
91
+
92
  FROM base AS run
93
  COPY --link --chown=1000 ./ /home/user/app
 
94
  COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt
95
+
96
  ENV PYTHONPATH=$HOME/app \
97
+ PYTHONUNBUFFERED=1 \
98
+ HF_XET_HIGH_PERFORMANCE=1 \
99
+ GRADIO_ALLOW_FLAGGING=never \
100
+ GRADIO_FLAGGING_MODE=never \
101
+ GRADIO_CACHE_EXAMPLES=true \
102
+ GRADIO_NUM_PORTS=1 \
103
+ GRADIO_SERVER_NAME=0.0.0.0 \
104
+ GRADIO_SSR_MODE=True \
105
+ GRADIO_THEME=huggingface \
106
+ TQDM_POSITION=-1 \
107
+ TQDM_MININTERVAL=1 \
108
+ SYSTEM=spaces