Spaces:
Sleeping
Sleeping
Create DockerFile
Browse files- DockerFile +124 -0
DockerFile
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:19 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://pgp.mongodb.com/server-6.0.asc | \
|
87 |
+
gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
|
88 |
+
--dearmor
|
89 |
+
|
90 |
+
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
|
91 |
+
|
92 |
+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
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_19.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
|
112 |
+
|
113 |
+
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"]
|