Reality123b commited on
Commit
2aaa9bf
·
verified ·
1 Parent(s): 9e219b2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -14
Dockerfile CHANGED
@@ -1,45 +1,59 @@
1
  # Base stage for chat-ui
2
  FROM ghcr.io/huggingface/chat-ui:latest AS chat_ui_base
3
 
4
- # Add text-generation-inference as a separate stage
5
  FROM ghcr.io/huggingface/text-generation-inference:latest AS text_gen_inference
6
 
7
  # Final stage
8
  FROM ubuntu:20.04 AS final
9
 
10
- ARG MODEL_NAME
11
- ENV MODEL_NAME=${MODEL_NAME}
12
- ENV TZ=Europe/Paris \
13
- PORT=3000
14
 
15
- # Install MongoDB, netcat, and other dependencies
16
- RUN apt-get update && apt-get install -y gnupg curl lsb-release ca-certificates netcat && \
 
 
 
 
17
  curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb-archive-keyring.gpg && \
18
  echo "deb [signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu $(lsb_release -sc)/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list && \
19
- apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends mongodb-org nodejs curl && \
20
- rm -rf /var/lib/apt/lists/*
 
21
 
22
- # Create user and directories
23
  RUN useradd -m -u 1000 user && \
24
  mkdir /app && chown -R 1000:1000 /app && \
25
  mkdir /data && chown -R 1000:1000 /data
26
 
27
- # Switch to the "user" user
28
  USER user
29
 
30
  ENV HOME=/home/user \
31
  PATH=/home/user/.local/bin:$PATH
32
 
33
- # Copy files from chat-ui stage
34
  COPY --from=chat_ui_base --chown=1000 /app/node_modules /app/node_modules
35
  COPY --from=chat_ui_base --chown=1000 /app/package.json /app/package.json
36
  COPY --from=chat_ui_base --chown=1000 /app/build /app/build
 
37
  COPY --from=chat_ui_base --chown=1000 /app/.env /app/.env
 
38
  COPY --chown=1000 .env.local /app/.env.local
39
 
40
- # Copy entrypoint script
41
  COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
42
  RUN chmod +x /app/entrypoint.sh
43
 
 
 
 
 
 
 
 
44
  # Use the entrypoint script
45
- ENTRYPOINT [ "/app/entrypoint.sh" ]
 
1
  # Base stage for chat-ui
2
  FROM ghcr.io/huggingface/chat-ui:latest AS chat_ui_base
3
 
4
+ # Add text-generation-inference as a separate stage (Optional, if needed)
5
  FROM ghcr.io/huggingface/text-generation-inference:latest AS text_gen_inference
6
 
7
  # Final stage
8
  FROM ubuntu:20.04 AS final
9
 
10
+ # Set default values for build arguments (can be overridden during build)
11
+ ARG MODEL_NAME=TheBloke/Mistral-7B-OpenOrca-GPTQ
12
+ ARG TZ=Europe/Paris
13
+ ARG PORT=3000
14
 
15
+ ENV MODEL_NAME=${MODEL_NAME} \
16
+ TZ=${TZ} \
17
+ PORT=${PORT}
18
+
19
+ # Install necessary packages, including python3-dotenv
20
+ RUN apt-get update && apt-get install -y gnupg curl lsb-release ca-certificates netcat python3-pip && \
21
  curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb-archive-keyring.gpg && \
22
  echo "deb [signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu $(lsb_release -sc)/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list && \
23
+ apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends mongodb-org nodejs && \
24
+ rm -rf /var/lib/apt/lists/* && \
25
+ python3 -m pip install python-dotenv # Install python-dotenv
26
 
27
+ # Create user and directories with proper permissions
28
  RUN useradd -m -u 1000 user && \
29
  mkdir /app && chown -R 1000:1000 /app && \
30
  mkdir /data && chown -R 1000:1000 /data
31
 
32
+ # Switch to the non-root "user" user
33
  USER user
34
 
35
  ENV HOME=/home/user \
36
  PATH=/home/user/.local/bin:$PATH
37
 
38
+ # Copy files from chat-ui stage with correct ownership
39
  COPY --from=chat_ui_base --chown=1000 /app/node_modules /app/node_modules
40
  COPY --from=chat_ui_base --chown=1000 /app/package.json /app/package.json
41
  COPY --from=chat_ui_base --chown=1000 /app/build /app/build
42
+ # Assuming .env contains default environment variables for chat-ui
43
  COPY --from=chat_ui_base --chown=1000 /app/.env /app/.env
44
+ # Copy .env.local from your project root, if it exists
45
  COPY --chown=1000 .env.local /app/.env.local
46
 
47
+ # Copy entrypoint script and make it executable
48
  COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
49
  RUN chmod +x /app/entrypoint.sh
50
 
51
+ # Set working directory (optional, but good practice)
52
+ WORKDIR /app
53
+
54
+ # Update system configuration for MongoDB (vm.max_map_count)
55
+ # This needs to be done at runtime, not during the build, so it's moved to entrypoint.sh
56
+ # RUN echo "vm.max_map_count=1677720" >> /etc/sysctl.conf # Not recommended here
57
+
58
  # Use the entrypoint script
59
+ ENTRYPOINT [ "/app/entrypoint.sh" ]