jameszokah commited on
Commit
5b49b7d
·
1 Parent(s): 383520d

updated the Dockerfile to include the user with permission

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -9
Dockerfile CHANGED
@@ -41,20 +41,29 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
41
  && apt-get clean \
42
  && rm -rf /var/lib/apt/lists/*
43
 
 
 
 
 
 
 
 
 
44
  # Set working directory
45
- WORKDIR /app
46
 
47
  # Copy requirements first for better caching
48
- COPY requirements.txt .
49
 
50
  # Create and set up persistent directories with proper permissions
51
- RUN mkdir -p /app/static /app/models /app/voice_memories /app/voice_references \
52
- /app/voice_profiles /app/cloned_voices /app/audio_cache /app/tokenizers /app/logs && \
53
- chmod -R 777 /app/voice_references /app/voice_profiles /app/voice_memories \
54
- /app/cloned_voices /app/audio_cache /app/static /app/logs /app/tokenizers /app/models
 
55
 
56
  # Copy static files
57
- COPY ./static /app/static
58
 
59
  # Install Python dependencies
60
  RUN pip3 install --no-cache-dir --upgrade pip && \
@@ -77,10 +86,10 @@ RUN pip3 install -r requirements.txt
77
  RUN pip3 install yt-dlp openai-whisper
78
 
79
  # Copy application code
80
- COPY ./app /app/app
81
 
82
  # Copy downloaded model from the model-downloader stage
83
- COPY --from=model-downloader /model-downloader/models /app/models
84
 
85
  # Show available models in torchtune
86
  RUN python3 -c "import torchtune.models; print('Available models in torchtune:', dir(torchtune.models))"
 
41
  && apt-get clean \
42
  && rm -rf /var/lib/apt/lists/*
43
 
44
+ # Create user and set up environment
45
+ RUN useradd -m -u 1000 user
46
+
47
+ USER user
48
+
49
+ ENV HOME=/home/user \
50
+ PATH=/home/user/.local/bin:$PATH
51
+
52
  # Set working directory
53
+ WORKDIR $HOME/app
54
 
55
  # Copy requirements first for better caching
56
+ COPY --chown=user:user requirements.txt .
57
 
58
  # Create and set up persistent directories with proper permissions
59
+ RUN mkdir -p $HOME/app/static $HOME/app/models $HOME/app/voice_memories $HOME/app/voice_references \
60
+ $HOME/app/voice_profiles $HOME/app/cloned_voices $HOME/app/audio_cache $HOME/app/tokenizers $HOME/app/logs && \
61
+ chmod -R 755 $HOME/app && \
62
+ chmod -R 777 $HOME/app/voice_references $HOME/app/voice_profiles $HOME/app/voice_memories \
63
+ $HOME/app/cloned_voices $HOME/app/audio_cache $HOME/app/static $HOME/app/logs $HOME/app/tokenizers $HOME/app/models
64
 
65
  # Copy static files
66
+ COPY --chown=user:user ./static $HOME/app/static
67
 
68
  # Install Python dependencies
69
  RUN pip3 install --no-cache-dir --upgrade pip && \
 
86
  RUN pip3 install yt-dlp openai-whisper
87
 
88
  # Copy application code
89
+ COPY --chown=user:user ./app $HOME/app/app
90
 
91
  # Copy downloaded model from the model-downloader stage
92
+ COPY --chown=user:user --from=model-downloader /model-downloader/models $HOME/app/models
93
 
94
  # Show available models in torchtune
95
  RUN python3 -c "import torchtune.models; print('Available models in torchtune:', dir(torchtune.models))"