Spaces:
Building
Building
File size: 6,805 Bytes
bb1671d a5972e1 bb1671d 36d3e3a bb1671d 6431a77 5d31eb6 6431a77 5d31eb6 6431a77 5d31eb6 6431a77 5d31eb6 6431a77 5d31eb6 6431a77 5d31eb6 6431a77 3393fee bb1671d 6431a77 3393fee bb1671d |
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
ARG MODEL_NAME
ARG MODEL_PARAMS
ARG MODEL_PROMPT_TEMPLATE
ARG APP_COLOR
ARG APP_NAME
FROM node:20 as chatui-builder
ARG MODEL_NAME
ARG MODEL_PARAMS
ARG APP_COLOR
ARG APP_NAME
ARG MODEL_PROMPT_TEMPLATE
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 --branch v0.8.4 https://github.com/huggingface/chat-ui.git
WORKDIR /app/chat-ui
COPY .env.local.template .env.local.template
RUN mkdir defaults
ADD defaults /defaults
RUN chmod -R 777 /defaults
RUN --mount=type=secret,id=OPENAI_API_KEY,mode=0444 \
OPENAI_API_KEY=$(cat /run/secrets/OPENAI_API_KEY) && export OPENAI_API_KEY && echo "${OPENAI_API_KEY}" >> "/defaults/.openai.key" && cat /defaults/.openai.key
RUN --mount=type=secret,id=ENDPOINT,mode=0444 \
ENDPOINT=$(cat /run/secrets/ENDPOINT) && export ENDPOINT && echo "${ENDPOINT}" >> "/defaults/.endpoint" && cat /defaults/.endpoint
RUN --mount=type=secret,id=GEMINI_API_KEY,mode=0444 \
GEMINI_API_KEY=$(cat /run/secrets/GEMINI_API_KEY) && export GEMINI_API_KEY && echo "${GEMINI_API_KEY}" >> "/defaults/.gemini.key" && cat /defaults/.gemini.key
RUN --mount=type=secret,id=FREEGPT_API_KEY,mode=0444 \
FREEGPT_API_KEY=$(cat /run/secrets/FREEGPT_API_KEY) && export FREEGPT_API_KEY && echo "${FREEGPT_API_KEY}" >> "/defaults/.freegpt.key" && cat /defaults/.freegpt.key
RUN --mount=type=secret,id=GROQ_API_KEY,mode=0444 \
GROQ_API_KEY=$(cat /run/secrets/GROQ_API_KEY) && export GROQ_API_KEY && echo "${GROQ_API_KEY}" >> "/defaults/.groq.key" && cat /defaults/.groq.key
RUN --mount=type=secret,id=VISIONCRAFT_API_KEY,mode=0444 \
VISIONCRAFT_API_KEY=$(cat /run/secrets/VISIONCRAFT_API_KEY) && export VISIONCRAFT_API_KEY && echo "${VISIONCRAFT_API_KEY}" >> "/defaults/.visioncraft.key" && cat /defaults/.visioncraft.key
RUN --mount=type=secret,id=OPENID_CLIENT_ID,mode=0444 \
OPENID_CLIENT_ID=$(cat /run/secrets/OPENID_CLIENT_ID) && export OPENID_CLIENT_ID && echo "${OPENID_CLIENT_ID}" >> "/defaults/.openid.client_id" && cat /defaults/.openid.client_id
RUN --mount=type=secret,id=OPENID_CLIENT_SECRET,mode=0444 \
OPENID_CLIENT_SECRET=$(cat /run/secrets/OPENID_CLIENT_SECRET) && export OPENID_CLIENT_SECRET && echo "${OPENID_CLIENT_SECRET}" >> "/defaults/.openid.client_secret" && cat /defaults/.openid.client_secret
RUN --mount=type=secret,id=HF_TOKEN,mode=0444 \
HF_TOKEN=$(cat /run/secrets/HF_TOKEN) && export OPENID_CLIENT_SECRET && echo "${HF_TOKEN}" >> "/defaults/.hf.token" && cat /defaults/.hf.token
RUN --mount=type=secret,id=MONGODB_URL,mode=0444 \
MODEL_NAME="${MODEL_NAME:="$(cat /defaults/MODEL_NAME)"}" && export MODEL_NAME \
&& MODEL_PARAMS="${MODEL_PARAMS:="$(cat /defaults/MODEL_PARAMS)"}" && export MODEL_PARAMS \
&& MODEL_PROMPT_TEMPLATE="${MODEL_PROMPT_TEMPLATE:="$(cat /defaults/MODEL_PROMPT_TEMPLATE)"}" && export MODEL_PROMPT_TEMPLATE \
&& APP_COLOR="${APP_COLOR:="$(cat /defaults/APP_COLOR)"}" && export APP_COLOR \
&& APP_NAME="${APP_NAME:="$(cat /defaults/APP_NAME)"}" && export APP_NAME \
&& MONGODB_URL=$(cat /run/secrets/MONGODB_URL || cat /defaults/MONGODB_URL) && export MONGODB_URL && \
echo "${MONGODB_URL}" && OPENAI_API_KEY=$(cat /defaults/.openai.key) && export OPENAI_API_KEY && echo "${OPENAI_API_KEY}" \
&& ENDPOINT=$(cat /defaults/.endpoint) && export ENDPOINT && echo "${ENDPOINT}" \
&& GEMINI_API_KEY=$(cat /defaults/.gemini.key) && export GEMINI_API_KEY && echo "${GEMINI_API_KEY}" \
&& FREEGPT_API_KEY=$(cat /defaults/.freegpt.key) && export FREEGPT_API_KEY && echo "${FREEGPT_API_KEY}" \
&& GROQ_API_KEY=$(cat /defaults/.groq.key) && export GROQ_API_KEY && echo "${GROQ_API_KEY}" \
&& VISIONCRAFT_API_KEY=$(cat /defaults/.visioncraft.key) && export VISIONCRAFT_API_KEY && echo "${VISIONCRAFT_API_KEY}" \
&& OPENID_CLIENT_ID=$(cat /defaults/.openid.client_id) && export OPENID_CLIENT_ID && echo "${OPENID_CLIENT_ID}" \
&& OPENID_CLIENT_SECRET=$(cat /defaults/.openid.client_secret) && export OPENID_CLIENT_SECRET && echo "${OPENID_CLIENT_SECRET}" \
&& HF_TOKEN=$(cat /defaults/.hf.token) && export HF_TOKEN && echo "${HF_TOKEN}" \
&& envsubst < ".env.local.template" > ".env.local" \
&& rm .env.local.template && cat .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
ARG MODEL_NAME
ARG MODEL_PARAMS
ARG MODEL_PROMPT_TEMPLATE
ARG APP_COLOR
ARG APP_NAME
ENV TZ=Europe/Paris \
PORT=3000
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
gnupg \
curl \
gettext && \
rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh.template entrypoint.sh.template
RUN mkdir defaults
ADD defaults /defaults
RUN chmod -R 777 /defaults
RUN --mount=type=secret,id=MONGODB_URL,mode=0444 \
MODEL_NAME="${MODEL_NAME:="$(cat /defaults/MODEL_NAME)"}" && export MODEL_NAME \
&& MODEL_PARAMS="${MODEL_PARAMS:="$(cat /defaults/MODEL_PARAMS)"}" && export MODEL_PARAMS \
&& MODEL_PROMPT_TEMPLATE="${MODEL_PROMPT_TEMPLATE:="$(cat /defaults/MODEL_PROMPT_TEMPLATE)"}" && export MODEL_PROMPT_TEMPLATE \
&& APP_COLOR="${APP_COLOR:="$(cat /defaults/APP_COLOR)"}" && export APP_COLOR \
&& APP_NAME="${APP_NAME:="$(cat /defaults/APP_NAME)"}" && export APP_NAME \
&& MONGODB_URL=$(cat /run/secrets/MONGODB_URL > /dev/null | grep '^' || cat /defaults/MONGODB_URL) && export MONGODB_URL && \
envsubst < "entrypoint.sh.template" > "entrypoint.sh" \
&& rm entrypoint.sh.template
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 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"]
|