Luigi commited on
Commit
7875635
·
1 Parent(s): 9b52ba8

update dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -15
Dockerfile CHANGED
@@ -1,47 +1,45 @@
1
- # 1. Start from the official slim Python image
2
  FROM python:3.10-slim
3
 
4
- # 2. Disable interactive prompts and set timezone to UTC
5
  ENV DEBIAN_FRONTEND=noninteractive \
6
  TZ=Etc/UTC \
7
  XDG_CACHE_HOME=/tmp/.cache \
8
  HF_HOME=/tmp/.cache/huggingface
9
 
10
- # 3. Use bash in strict mode for reliable builds
11
  SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
12
 
13
- # 4. Preseed tzdata, install system deps (git, cmake, build tools, OpenBLAS), then clean up
14
- RUN echo "tzdata tzdata/Areas select Etc" > /tmp/tzdata.seed \
15
- && echo "tzdata tzdata/Zones/Etc select UTC" >> /tmp/tzdata.seed \
16
- && apt-get update \
17
  && apt-get install -y --no-install-recommends \
18
  tzdata \
19
  git \
20
  cmake \
21
  build-essential \
22
  libopenblas-dev \
23
- && rm -rf /var/lib/apt/lists/* \
24
- && cp /usr/share/zoneinfo/Etc/UTC /etc/localtime \
25
- && echo "Etc/UTC" > /etc/timezone
26
 
27
- # 5. Create cache directories with proper permissions
28
  RUN mkdir -p "$XDG_CACHE_HOME" "$HF_HOME" \
29
  && chmod -R a+rwX "$XDG_CACHE_HOME" "$HF_HOME"
30
 
31
- # 6. Build and install llama-cpp-python from source with OpenBLAS support
32
  RUN git clone --depth 1 --recurse-submodules \
33
  https://github.com/abetlen/llama-cpp-python.git /tmp/llama-cpp-python \
34
  && cd /tmp/llama-cpp-python \
35
  && CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install . \
36
  && rm -rf /tmp/llama-cpp-python
37
 
38
- # 7. (Optional) Install any other Python deps your app needs
39
  # COPY requirements.txt .
40
  # RUN pip install --no-cache-dir -r requirements.txt
41
 
42
- # 8. Copy in your application code
43
  COPY . .
44
 
45
- # 9. Expose the HF Spaces port and set the default command
46
  EXPOSE 7860
47
  CMD ["python3", "app.py"]
 
1
+ # 1. Base image
2
  FROM python:3.10-slim
3
 
4
+ # 2. Noninteractive + timezone
5
  ENV DEBIAN_FRONTEND=noninteractive \
6
  TZ=Etc/UTC \
7
  XDG_CACHE_HOME=/tmp/.cache \
8
  HF_HOME=/tmp/.cache/huggingface
9
 
10
+ # 3. Use bash strict mode
11
  SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
12
 
13
+ # 4. Install system deps and set timezone
14
+ RUN apt-get update \
 
 
15
  && apt-get install -y --no-install-recommends \
16
  tzdata \
17
  git \
18
  cmake \
19
  build-essential \
20
  libopenblas-dev \
21
+ && ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
22
+ && echo $TZ > /etc/timezone \
23
+ && rm -rf /var/lib/apt/lists/*
24
 
25
+ # 5. Prepare cache dirs
26
  RUN mkdir -p "$XDG_CACHE_HOME" "$HF_HOME" \
27
  && chmod -R a+rwX "$XDG_CACHE_HOME" "$HF_HOME"
28
 
29
+ # 6. Build llama-cpp-python with OpenBLAS
30
  RUN git clone --depth 1 --recurse-submodules \
31
  https://github.com/abetlen/llama-cpp-python.git /tmp/llama-cpp-python \
32
  && cd /tmp/llama-cpp-python \
33
  && CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" pip install . \
34
  && rm -rf /tmp/llama-cpp-python
35
 
36
+ # 7. (Optional) Your other Python deps
37
  # COPY requirements.txt .
38
  # RUN pip install --no-cache-dir -r requirements.txt
39
 
40
+ # 8. Copy app code
41
  COPY . .
42
 
43
+ # 9. Expose & run
44
  EXPOSE 7860
45
  CMD ["python3", "app.py"]