nsarrazin HF staff commited on
Commit
cc8dcea
·
verified ·
1 Parent(s): fa6e93e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -91
Dockerfile CHANGED
@@ -1,113 +1,43 @@
1
- ARG MODEL_NAME
2
- ARG MODEL_PARAMS
3
- ARG MODEL_PROMPT_TEMPLATE
4
- ARG APP_COLOR
5
- ARG APP_NAME
6
-
7
-
8
- FROM node:20 as chatui-builder
9
- ARG MODEL_NAME
10
- ARG MODEL_PARAMS
11
- ARG APP_COLOR
12
- ARG APP_NAME
13
- ARG MODEL_PROMPT_TEMPLATE
14
-
15
- WORKDIR /app
16
-
17
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
18
- git gettext && \
19
- rm -rf /var/lib/apt/lists/*
20
-
21
-
22
- RUN git clone https://github.com/huggingface/chat-ui.git
23
-
24
- WORKDIR /app/chat-ui
25
-
26
- COPY .env.local.template .env.local.template
27
-
28
- RUN rm entrypoint.sh
29
-
30
- RUN mkdir defaults
31
- ADD defaults /defaults
32
- RUN chmod -R 777 /defaults
33
- RUN --mount=type=secret,id=MONGODB_URL,mode=0444 \
34
- MODEL_NAME="${MODEL_NAME:="$(cat /defaults/MODEL_NAME)"}" && export MODEL_NAME \
35
- && MODEL_PARAMS="${MODEL_PARAMS:="$(cat /defaults/MODEL_PARAMS)"}" && export MODEL_PARAMS \
36
- && MODEL_PROMPT_TEMPLATE="${MODEL_PROMPT_TEMPLATE:="$(cat /defaults/MODEL_PROMPT_TEMPLATE)"}" && export MODEL_PROMPT_TEMPLATE \
37
- && APP_COLOR="${APP_COLOR:="$(cat /defaults/APP_COLOR)"}" && export APP_COLOR \
38
- && APP_NAME="${APP_NAME:="$(cat /defaults/APP_NAME)"}" && export APP_NAME \
39
- && MONGODB_URL=$(cat /run/secrets/MONGODB_URL > /dev/null | grep '^' || cat /defaults/MONGODB_URL) && export MONGODB_URL && \
40
- echo "${MONGODB_URL}" && \
41
- envsubst < ".env.local.template" > ".env.local" \
42
- && rm .env.local.template
43
-
44
 
45
-
46
- RUN --mount=type=cache,target=/app/.npm \
47
- npm set cache /app/.npm && \
48
- npm ci
49
-
50
- RUN npm run build
51
-
52
- FROM ghcr.io/huggingface/text-generation-inference:latest
53
 
54
  ARG MODEL_NAME
55
- ARG MODEL_PARAMS
56
- ARG MODEL_PROMPT_TEMPLATE
57
- ARG APP_COLOR
58
- ARG APP_NAME
59
 
60
  ENV TZ=Europe/Paris \
61
  PORT=3000
62
 
63
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
64
- gnupg \
65
- curl \
66
- wget \
67
- gettext && \
68
- rm -rf /var/lib/apt/lists/*
69
- COPY entrypoint.sh.template entrypoint.sh.template
70
-
71
- RUN mkdir defaults
72
- ADD defaults /defaults
73
- RUN chmod -R 777 /defaults
74
-
75
- RUN --mount=type=secret,id=MONGODB_URL,mode=0444 \
76
- MODEL_NAME="${MODEL_NAME:="$(cat /defaults/MODEL_NAME)"}" && export MODEL_NAME \
77
- && MODEL_PARAMS="${MODEL_PARAMS:="$(cat /defaults/MODEL_PARAMS)"}" && export MODEL_PARAMS \
78
- && MODEL_PROMPT_TEMPLATE="${MODEL_PROMPT_TEMPLATE:="$(cat /defaults/MODEL_PROMPT_TEMPLATE)"}" && export MODEL_PROMPT_TEMPLATE \
79
- && APP_COLOR="${APP_COLOR:="$(cat /defaults/APP_COLOR)"}" && export APP_COLOR \
80
- && APP_NAME="${APP_NAME:="$(cat /defaults/APP_NAME)"}" && export APP_NAME \
81
- && MONGODB_URL=$(cat /run/secrets/MONGODB_URL > /dev/null | grep '^' || cat /defaults/MONGODB_URL) && export MONGODB_URL && \
82
- envsubst < "entrypoint.sh.template" > "entrypoint.sh" \
83
- && rm entrypoint.sh.template
84
-
85
- RUN wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
86
- RUN dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
87
 
88
- RUN curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
89
- gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
90
- --dearmor
 
91
 
92
- RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
93
 
94
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
95
  mongodb-org && \
96
  rm -rf /var/lib/apt/lists/*
97
 
98
- RUN mkdir -p /data/db
99
- RUN chown -R 1000:1000 /data
100
-
101
  RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash -
102
 
103
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
104
  nodejs && \
105
  rm -rf /var/lib/apt/lists/*
106
 
 
107
  RUN mkdir /app
108
  RUN chown -R 1000:1000 /app
109
 
110
  RUN useradd -m -u 1000 user
 
 
 
 
 
 
111
  # Switch to the "user" user
112
  USER user
113
 
@@ -117,11 +47,14 @@ ENV HOME=/home/user \
117
  RUN npm config set prefix /home/user/.local
118
  RUN npm install -g pm2
119
 
120
- COPY --from=chatui-builder --chown=1000 /app/chat-ui/node_modules /app/node_modules
121
- COPY --from=chatui-builder --chown=1000 /app/chat-ui/package.json /app/package.json
122
- COPY --from=chatui-builder --chown=1000 /app/chat-ui/build /app/build
123
 
124
- ENTRYPOINT ["/bin/bash"]
125
- CMD ["entrypoint.sh"]
 
 
 
126
 
 
127
 
 
 
 
1
+ FROM ghcr.io/huggingface/chat-ui:latest AS base
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ FROM ghcr.io/huggingface/text-generation-inference:latest AS final
 
 
 
 
 
 
 
4
 
5
  ARG MODEL_NAME
6
+ ENV MODEL_NAME=${MODEL_NAME}
 
 
 
7
 
8
  ENV TZ=Europe/Paris \
9
  PORT=3000
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ # mongo installation
13
+ RUN curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
14
+ gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
15
+ --dearmor
16
 
17
+ RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
18
 
19
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
20
  mongodb-org && \
21
  rm -rf /var/lib/apt/lists/*
22
 
23
+ # node installation
 
 
24
  RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash -
25
 
26
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
27
  nodejs && \
28
  rm -rf /var/lib/apt/lists/*
29
 
30
+ # image setup
31
  RUN mkdir /app
32
  RUN chown -R 1000:1000 /app
33
 
34
  RUN useradd -m -u 1000 user
35
+
36
+ RUN chown -R 1000:1000 /app
37
+
38
+ RUN mkdir /data
39
+ RUN chown -R 1000:1000 /data
40
+
41
  # Switch to the "user" user
42
  USER user
43
 
 
47
  RUN npm config set prefix /home/user/.local
48
  RUN npm install -g pm2
49
 
 
 
 
50
 
51
+ # copy chat-ui from base image
52
+ COPY --from=base --chown=1000 /app/node_modules /app/node_modules
53
+ COPY --from=base --chown=1000 /app/package.json /app/package.json
54
+ COPY --from=base --chown=1000 /app/build /app/build
55
+ COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
56
 
57
+ RUN chmod +x /app/entrypoint.sh
58
 
59
+ # entrypoint
60
+ ENTRYPOINT [ "/app/entrypoint.sh" ]