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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -48
Dockerfile CHANGED
@@ -1,59 +1,60 @@
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" ]
 
1
+ FROM ghcr.io/huggingface/chat-ui:latest AS base
2
+
3
+ FROM ghcr.io/huggingface/text-generation-inference:latest AS final
4
+
5
+ ARG MODEL_NAME
6
+ ENV MODEL_NAME=${MODEL_NAME}
7
+
8
+ ENV TZ=Europe/Paris \
9
+ PORT=3000
10
+
11
+ # mongo installation
12
+ RUN curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
13
+ gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
14
+ --dearmor
15
+
16
+ RUN echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
17
+
18
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
19
+ mongodb-org && \
20
+ rm -rf /var/lib/apt/lists/*
21
+
22
+ # node installation
23
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | /bin/bash -
24
+
25
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
26
+ nodejs && \
27
+ rm -rf /var/lib/apt/lists/*
28
+
29
+ # image setup
30
+ RUN useradd -m -u 1000 user
31
+
32
+ RUN mkdir /app
33
+ RUN chown -R 1000:1000 /app
34
+ RUN mkdir /data
35
+ RUN chown -R 1000:1000 /data
36
+
37
+ # Switch to the "user" user
38
  USER user
39
 
40
  ENV HOME=/home/user \
41
  PATH=/home/user/.local/bin:$PATH
42
 
43
+ RUN npm config set prefix /home/user/.local
44
+ RUN npm install -g dotenv-cli
45
+
46
+
47
+ # copy chat-ui from base image
48
+ COPY --from=base --chown=1000 /app/node_modules /app/node_modules
49
+ COPY --from=base --chown=1000 /app/package.json /app/package.json
50
+ COPY --from=base --chown=1000 /app/build /app/build
51
+
52
+ COPY --from=base --chown=1000 /app/.env /app/.env
53
  COPY --chown=1000 .env.local /app/.env.local
54
 
 
55
  COPY --chown=1000 entrypoint.sh /app/entrypoint.sh
 
56
 
57
+ RUN chmod +x /app/entrypoint.sh
 
 
 
 
 
58
 
59
+ # entrypoint
60
  ENTRYPOINT [ "/app/entrypoint.sh" ]