enskaff commited on
Commit
8ced1ba
·
verified ·
1 Parent(s): 1b85b71

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -16
Dockerfile CHANGED
@@ -1,39 +1,45 @@
1
- ARG HF_TOKEN
2
- ENV HF_TOKEN=${HF_TOKEN}
3
-
4
- # This diagnostic line checks if HF_TOKEN is set
5
- RUN if [ -z "$HF_TOKEN" ]; then \
6
- echo "ERROR: HF_TOKEN is not set!" && exit 1; \
7
- else \
8
- echo "HF_TOKEN is set (but not displaying the value for security)." ; \
9
- fi
10
-
11
- # Use the NVIDIA CUDA runtime image for GPU support
12
  FROM nvidia/cuda:12.1.0-runtime-ubuntu20.04
13
 
14
  # Set environment variables
15
  ENV DEBIAN_FRONTEND=noninteractive \
16
  PIP_NO_CACHE_DIR=off \
17
  PIP_DISABLE_PIP_VERSION_CHECK=on \
18
- PATH="/root/.cargo/bin:${PATH}" \
19
  PYTHONIOENCODING=utf-8 \
20
  PYTHONUNBUFFERED=1
21
 
22
- # Install system dependencies
23
  RUN apt-get update && apt-get install -y --no-install-recommends \
24
  git git-lfs python3 python3-pip curl ca-certificates build-essential && \
25
  apt-get clean && rm -rf /var/lib/apt/lists/*
26
 
27
- # Install Rust (required for compiling tokenizers if needed)
28
  RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
29
 
30
- # Set the working directory and install Python dependencies
31
  WORKDIR /app
32
  COPY requirements.txt .
33
  RUN pip3 install --no-cache-dir --upgrade pip && \
34
  pip3 install --no-cache-dir -r requirements.txt
35
 
36
- # Use build-time argument for Hugging Face token
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ARG HF_TOKEN
38
 
39
  # Download the model during build
 
1
+ # syntax=docker/dockerfile:1
 
 
 
 
 
 
 
 
 
 
2
  FROM nvidia/cuda:12.1.0-runtime-ubuntu20.04
3
 
4
  # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive \
6
  PIP_NO_CACHE_DIR=off \
7
  PIP_DISABLE_PIP_VERSION_CHECK=on \
 
8
  PYTHONIOENCODING=utf-8 \
9
  PYTHONUNBUFFERED=1
10
 
11
+ # Install required system packages
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
13
  git git-lfs python3 python3-pip curl ca-certificates build-essential && \
14
  apt-get clean && rm -rf /var/lib/apt/lists/*
15
 
16
+ # Install Rust (if needed for building dependencies)
17
  RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
18
 
19
+ # Set working directory and install Python dependencies
20
  WORKDIR /app
21
  COPY requirements.txt .
22
  RUN pip3 install --no-cache-dir --upgrade pip && \
23
  pip3 install --no-cache-dir -r requirements.txt
24
 
25
+ # Download the model using BuildKit secret mount.
26
+ # This command uses the secret HF_TOKEN, which is passed only during this RUN and not stored in the image.
27
+ RUN --mount=type=secret,id=HF_TOKEN,env=HF_TOKEN \
28
+ python3 -c "import os; \
29
+ from huggingface_hub import snapshot_download; \
30
+ token = os.getenv('HF_TOKEN'); \
31
+ assert token, 'HF_TOKEN is not set!'; \
32
+ snapshot_download(repo_id='mistralai/Mistral-7B-Instruct-v0.1', local_dir='/app/model', token=token)"
33
+
34
+ # Expose port 8000
35
+ EXPOSE 8000
36
+
37
+ # Healthcheck (optional)
38
+ HEALTHCHECK --interval=20s --timeout=10s --start-period=120s --retries=3 \
39
+ CMD curl --fail http://localhost:8000/health || exit 1
40
+
41
+ # Set the entrypoint to run the vLLM API server
42
+ CMD ["python3", "-m", "vllm.entrypoints.openai.api_server", "--model", "/app/model"]
43
  ARG HF_TOKEN
44
 
45
  # Download the model during build