nsarrazin HF staff commited on
Commit
29f5c96
β€’
1 Parent(s): 9ac2269

use inject & templates

Browse files
Dockerfile CHANGED
@@ -13,20 +13,17 @@ WORKDIR /app/chat-ui
13
 
14
 
15
  COPY .template.env.local .template.env.local
16
-
17
  RUN mkdir defaults
18
  ADD defaults /defaults
19
  RUN chmod -R 777 /defaults
 
20
  RUN --mount=type=secret,id=MODEL_NAME,mode=0444 \
21
  --mount=type=secret,id=MODEL_PARAMS,mode=0444 \
22
  --mount=type=secret,id=MONGODB_URL,mode=0444 \
23
  --mount=type=secret,id=APP_COLOR,mode=0444 \
24
  --mount=type=secret,id=APP_NAME,mode=0444 \
25
- MODEL_NAME=$(cat /run/secrets/MODEL_NAME 2> /dev/null | grep '^' || cat /defaults/MODEL_NAME) && export MODEL_NAME \
26
- && MODEL_PARAMS=$(cat /run/secrets/MODEL_PARAMS 2> /dev/null | grep '^' ||cat /defaults/MODEL_PARAMS) && export MODEL_PARAMS \
27
- && MONGODB_URL=$(cat /run/secrets/MONGODB_URL 2> /dev/null | grep '^' || cat /defaults/MONGODB_URL) && export MONGODB_URL \
28
- && APP_COLOR=$(cat /run/secrets/APP_COLOR 2> /dev/null | grep '^' || cat /defaults/APP_COLOR) && export APP_COLOR \
29
- && APP_NAME=$(cat /run/secrets/APP_NAME 2> /dev/null | grep '^' || cat /defaults/APP_NAME) && export APP_NAME \
30
  && envsubst < ".template.env.local" > ".env.local"
31
 
32
 
@@ -42,19 +39,20 @@ FROM ghcr.io/huggingface/text-generation-inference:latest
42
  ENV TZ=Europe/Paris \
43
  PORT=3000
44
 
 
 
 
45
  RUN mkdir defaults
46
  ADD defaults /defaults
47
  RUN chmod -R 777 /defaults
 
48
  RUN --mount=type=secret,id=MODEL_NAME,mode=0444 \
49
  --mount=type=secret,id=MODEL_PARAMS,mode=0444 \
50
  --mount=type=secret,id=MONGODB_URL,mode=0444 \
51
  --mount=type=secret,id=APP_COLOR,mode=0444 \
52
  --mount=type=secret,id=APP_NAME,mode=0444 \
53
- MODEL_NAME=$(cat /run/secrets/MODEL_NAME 2> /dev/null | grep '^' || cat /defaults/MODEL_NAME) && export MODEL_NAME \
54
- && MODEL_PARAMS=$(cat /run/secrets/MODEL_PARAMS 2> /dev/null | grep '^' ||cat /defaults/MODEL_PARAMS) && export MODEL_PARAMS \
55
- && MONGODB_URL=$(cat /run/secrets/MONGODB_URL 2> /dev/null | grep '^' || cat /defaults/MONGODB_URL) && export MONGODB_URL \
56
- && APP_COLOR=$(cat /run/secrets/APP_COLOR 2> /dev/null | grep '^' || cat /defaults/APP_COLOR) && export APP_COLOR \
57
- && APP_NAME=$(cat /run/secrets/APP_NAME 2> /dev/null | grep '^' || cat /defaults/APP_NAME) && export APP_NAME;
58
 
59
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
60
  gnupg \
 
13
 
14
 
15
  COPY .template.env.local .template.env.local
16
+ COPY --chmod=777 inject.sh inject.sh
17
  RUN mkdir defaults
18
  ADD defaults /defaults
19
  RUN chmod -R 777 /defaults
20
+
21
  RUN --mount=type=secret,id=MODEL_NAME,mode=0444 \
22
  --mount=type=secret,id=MODEL_PARAMS,mode=0444 \
23
  --mount=type=secret,id=MONGODB_URL,mode=0444 \
24
  --mount=type=secret,id=APP_COLOR,mode=0444 \
25
  --mount=type=secret,id=APP_NAME,mode=0444 \
26
+ inject.sh \
 
 
 
 
27
  && envsubst < ".template.env.local" > ".env.local"
28
 
29
 
 
39
  ENV TZ=Europe/Paris \
40
  PORT=3000
41
 
42
+
43
+ COPY .template.env.local .template.env.local
44
+ COPY --chmod=777 inject.sh inject.sh
45
  RUN mkdir defaults
46
  ADD defaults /defaults
47
  RUN chmod -R 777 /defaults
48
+
49
  RUN --mount=type=secret,id=MODEL_NAME,mode=0444 \
50
  --mount=type=secret,id=MODEL_PARAMS,mode=0444 \
51
  --mount=type=secret,id=MONGODB_URL,mode=0444 \
52
  --mount=type=secret,id=APP_COLOR,mode=0444 \
53
  --mount=type=secret,id=APP_NAME,mode=0444 \
54
+ inject.sh \
55
+ && envsubst < "entrypoint.sh.template" > "entrypoint.sh"
 
 
 
56
 
57
  RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
58
  gnupg \
entrypoint.sh β†’ entrypoint.sh.template RENAMED
@@ -4,7 +4,7 @@
4
  mongod &
5
 
6
  # Start the text-generation-inference process
7
- text-generation-launcher --model-id $MODEL_NAME --num-shard 1 --port 8080 --trust-remote-code &
8
 
9
  # Wait for text-generation-inference to start
10
  curl --retry 60 --retry-delay 10 --retry-connrefused http://127.0.0.1:8080/health
 
4
  mongod &
5
 
6
  # Start the text-generation-inference process
7
+ text-generation-launcher --model-id ${MODEL_NAME} --num-shard 1 --port 8080 --trust-remote-code &
8
 
9
  # Wait for text-generation-inference to start
10
  curl --retry 60 --retry-delay 10 --retry-connrefused http://127.0.0.1:8080/health
inject.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ MODEL_NAME=$(cat /run/secrets/MODEL_NAME 2> /dev/null | grep '^' || cat /defaults/MODEL_NAME)
3
+ MODEL_PARAMS=$(cat /run/secrets/MODEL_PARAMS 2> /dev/null | grep '^' ||cat /defaults/MODEL_PARAMS)
4
+ MONGODB_URL=$(cat /run/secrets/MONGODB_URL 2> /dev/null | grep '^' || cat /defaults/MONGODB_URL)
5
+ APP_COLOR=$(cat /run/secrets/APP_COLOR 2> /dev/null | grep '^' || cat /defaults/APP_COLOR)
6
+ APP_NAME=$(cat /run/secrets/APP_NAME 2> /dev/null | grep '^' || cat /defaults/APP_NAME)
7
+ $*