File size: 2,888 Bytes
aee1b53
 
 
 
 
a4bdde3
aee1b53
 
9c74e91
aee1b53
 
 
 
fefa00b
e6835e7
29f5c96
9ac2269
 
 
29f5c96
19a9ea2
 
 
 
 
29f5c96
169eff3
1d26e73
a36deec
277f3f8
 
 
 
 
aee1b53
 
a040483
aee1b53
a040483
 
aee1b53
29f5c96
7b85210
29f5c96
9ac2269
 
 
29f5c96
9ac2269
 
 
 
 
29f5c96
 
9ac2269
a040483
 
 
 
aee1b53
a040483
 
 
aee1b53
a040483
aee1b53
a040483
 
 
aee1b53
a040483
 
aee1b53
a040483
aee1b53
a040483
 
 
aee1b53
a040483
 
aee1b53
a040483
aee1b53
42d9bcf
a040483
aee1b53
a040483
 
aee1b53
a040483
 
aee1b53
a040483
 
 
aee1b53
a040483
 
aee1b53
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
FROM node:19 as chatui-builder

WORKDIR /app

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    git gettext && \
    rm -rf /var/lib/apt/lists/*


RUN git clone https://github.com/huggingface/chat-ui.git

WORKDIR /app/chat-ui


COPY .template.env.local .template.env.local
COPY --chmod=777 inject.sh inject.sh
RUN mkdir defaults
ADD defaults /defaults
RUN chmod -R 777 /defaults

RUN --mount=type=secret,id=MODEL_NAME,mode=0444 \
    --mount=type=secret,id=MODEL_PARAMS,mode=0444 \
    --mount=type=secret,id=MONGODB_URL,mode=0444 \
    --mount=type=secret,id=APP_COLOR,mode=0444 \
    --mount=type=secret,id=APP_NAME,mode=0444 \
    inject.sh \
    && envsubst < ".template.env.local" > ".env.local"



RUN --mount=type=cache,target=/app/.npm \
    npm set cache /app/.npm && \
    npm ci

RUN npm run build

FROM ghcr.io/huggingface/text-generation-inference:latest

ENV TZ=Europe/Paris \
    PORT=3000


COPY entrypoint.sh.template entrypoint.sh.template
COPY --chmod=777 inject.sh inject.sh
RUN mkdir defaults
ADD defaults /defaults
RUN chmod -R 777 /defaults

RUN --mount=type=secret,id=MODEL_NAME,mode=0444 \
    --mount=type=secret,id=MODEL_PARAMS,mode=0444 \
    --mount=type=secret,id=MONGODB_URL,mode=0444 \
    --mount=type=secret,id=APP_COLOR,mode=0444 \
    --mount=type=secret,id=APP_NAME,mode=0444 \
    inject.sh \
    && envsubst < "entrypoint.sh.template" > "entrypoint.sh"

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    gnupg \
    curl && \
    rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
    gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
    --dearmor

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

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    mongodb-org && \
    rm -rf /var/lib/apt/lists/*

RUN mkdir -p /data/db
RUN chown -R 1000:1000 /data

RUN curl -fsSL https://deb.nodesource.com/setup_19.x | /bin/bash -

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    nodejs && \
    rm -rf /var/lib/apt/lists/*

RUN mkdir /app
RUN chown -R 1000:1000 /app

RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user

ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

RUN npm config set prefix /home/user/.local
RUN npm install -g pm2

COPY --from=chatui-builder --chown=1000 /app/chat-ui/node_modules /app/node_modules
COPY --from=chatui-builder --chown=1000 /app/chat-ui/package.json /app/package.json
COPY --from=chatui-builder --chown=1000 /app/chat-ui/build /app/build

ENTRYPOINT ["/bin/bash"]
CMD ["entrypoint.sh"]