abubasith86 commited on
Commit
ec32a6f
·
verified ·
1 Parent(s): 6867ca4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -9
Dockerfile CHANGED
@@ -1,7 +1,17 @@
1
  FROM python:3.12-slim
2
 
3
- WORKDIR /app
4
-
 
 
 
 
 
 
 
 
 
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  libgl1 \
7
  libglib2.0-0 \
@@ -13,23 +23,29 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
13
  git \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Clone your repository directly to /app
 
 
 
17
  RUN git clone https://github.com/abubasith456/voice-agent.git .
18
 
19
- # Copy uv CLI tool
 
20
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
 
 
 
 
21
 
22
  # Create virtual environment
23
  RUN uv venv --system-site-packages .venv
24
 
25
- # Install dependencies (pyproject.toml is already in the cloned repo)
26
  RUN . .venv/bin/activate && \
27
  uv pip install -e . && \
28
- rm -rf ~/.cache/pip ~/.cache/uv
29
-
30
- ENV HF_HOME=/app/cache
31
 
32
- # Make entrypoint executable (should be in your git repo)
33
  RUN chmod +x ./entrypoint.sh
34
 
35
  EXPOSE 8000
 
1
  FROM python:3.12-slim
2
 
3
+ # Create user for Hugging Face (required)
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+ ENV HOME=/home/user \
7
+ PATH=/home/user/.local/bin:$PATH \
8
+ UV_CACHE_DIR=/home/user/.cache/uv \
9
+ HF_HOME=/home/user/.cache/huggingface
10
+
11
+ WORKDIR $HOME/app
12
+
13
+ # Install system dependencies as root
14
+ USER root
15
  RUN apt-get update && apt-get install -y --no-install-recommends \
16
  libgl1 \
17
  libglib2.0-0 \
 
23
  git \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
+ # Switch back to user
27
+ USER user
28
+
29
+ # Clone your repository to the correct location
30
  RUN git clone https://github.com/abubasith456/voice-agent.git .
31
 
32
+ # Copy uv CLI tool (as root)
33
+ USER root
34
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
35
+ USER user
36
+
37
+ # Create cache directories with proper permissions
38
+ RUN mkdir -p $UV_CACHE_DIR $HF_HOME
39
 
40
  # Create virtual environment
41
  RUN uv venv --system-site-packages .venv
42
 
43
+ # Install dependencies
44
  RUN . .venv/bin/activate && \
45
  uv pip install -e . && \
46
+ rm -rf $UV_CACHE_DIR
 
 
47
 
48
+ # Make entrypoint executable
49
  RUN chmod +x ./entrypoint.sh
50
 
51
  EXPOSE 8000