nsarrazin HF staff commited on
Commit
16eedf0
·
verified ·
1 Parent(s): aeae820

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -89
Dockerfile CHANGED
@@ -1,88 +1,14 @@
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
-
27
- COPY .env.local.template .env.local.template
28
-
29
- RUN mkdir defaults
30
- ADD defaults /defaults
31
- RUN chmod -R 777 /defaults
32
- RUN --mount=type=secret,id=MONGODB_URL,mode=0444 \
33
- MODEL_NAME="${MODEL_NAME:="$(cat /defaults/MODEL_NAME)"}" && export MODEL_NAME \
34
- && MODEL_PARAMS="${MODEL_PARAMS:="$(cat /defaults/MODEL_PARAMS)"}" && export MODEL_PARAMS \
35
- && MODEL_PROMPT_TEMPLATE="${MODEL_PROMPT_TEMPLATE:="$(cat /defaults/MODEL_PROMPT_TEMPLATE)"}" && export MODEL_PROMPT_TEMPLATE \
36
- && APP_COLOR="${APP_COLOR:="$(cat /defaults/APP_COLOR)"}" && export APP_COLOR \
37
- && APP_NAME="${APP_NAME:="$(cat /defaults/APP_NAME)"}" && export APP_NAME \
38
- && MONGODB_URL=$(cat /run/secrets/MONGODB_URL > /dev/null | grep '^' || cat /defaults/MONGODB_URL) && export MONGODB_URL && \
39
- echo "${MONGODB_URL}" && \
40
- envsubst < ".env.local.template" > ".env.local" \
41
- && rm .env.local.template
42
-
43
-
44
-
45
- RUN --mount=type=cache,target=/app/.npm \
46
- npm set cache /app/.npm && \
47
- npm ci
48
-
49
- RUN npm run build
50
 
51
- FROM ghcr.io/huggingface/text-generation-inference:latest
52
 
53
  ARG MODEL_NAME
54
- ARG MODEL_PARAMS
55
- ARG MODEL_PROMPT_TEMPLATE
56
- ARG APP_COLOR
57
- ARG APP_NAME
58
 
59
  ENV TZ=Europe/Paris \
60
  PORT=3000
61
 
62
-
63
-
64
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
65
- gnupg \
66
- curl \
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
-
86
  RUN curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
87
  gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
88
  --dearmor
@@ -93,19 +19,20 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
93
  mongodb-org && \
94
  rm -rf /var/lib/apt/lists/*
95
 
96
- RUN mkdir -p /data/db
97
- RUN chown -R 1000:1000 /data
98
-
99
  RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash -
100
 
101
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
102
  nodejs && \
103
  rm -rf /var/lib/apt/lists/*
104
 
 
 
 
105
  RUN mkdir /app
106
  RUN chown -R 1000:1000 /app
107
-
108
- RUN useradd -m -u 1000 user
109
 
110
  # Switch to the "user" user
111
  USER user
@@ -114,13 +41,20 @@ ENV HOME=/home/user \
114
  PATH=/home/user/.local/bin:$PATH
115
 
116
  RUN npm config set prefix /home/user/.local
117
- RUN npm install -g pm2
 
 
 
 
 
 
118
 
119
- COPY --from=chatui-builder --chown=1000 /app/chat-ui/node_modules /app/node_modules
120
- COPY --from=chatui-builder --chown=1000 /app/chat-ui/package.json /app/package.json
121
- COPY --from=chatui-builder --chown=1000 /app/chat-ui/build /app/build
122
 
123
- ENTRYPOINT ["/bin/bash"]
124
- CMD ["entrypoint.sh"]
125
 
 
126
 
 
 
 
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
+ # mongo installation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  RUN curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
13
  gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
14
  --dearmor
 
19
  mongodb-org && \
20
  rm -rf /var/lib/apt/lists/*
21
 
22
+ # node installation
 
 
23
  RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash -
24
 
25
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
26
  nodejs && \
27
  rm -rf /var/lib/apt/lists/*
28
 
29
+ # image setup
30
+ RUN useradd -m -u 1000 user
31
+
32
  RUN mkdir /app
33
  RUN chown -R 1000:1000 /app
34
+ RUN mkdir /data
35
+ RUN chown -R 1000:1000 /data
36
 
37
  # Switch to the "user" user
38
  USER user
 
41
  PATH=/home/user/.local/bin:$PATH
42
 
43
  RUN npm config set prefix /home/user/.local
44
+ RUN npm install -g dotenv-cli
45
+
46
+
47
+ # copy chat-ui from base image
48
+ COPY --from=base --chown=1000 /app/node_modules /app/node_modules
49
+ COPY --from=base --chown=1000 /app/package.json /app/package.json
50
+ COPY --from=base --chown=1000 /app/build /app/build
51
 
52
+ COPY --from=base --chown=1000 /app/.env /app/.env
53
+ COPY --chown=1000 .env.local /app/.env.local
 
54
 
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" ]