NanobotzAI commited on
Commit
88ecd98
·
verified ·
1 Parent(s): 3d58f4e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -37
Dockerfile CHANGED
@@ -1,61 +1,42 @@
1
- # Use an official Python image as a base
2
  FROM python:3.9
3
 
4
  # Set environment variables
5
  ENV PYTHONUNBUFFERED=1 \
6
  PORT=7860 \
7
- PYTHONPATH=/app \
8
- HOME=/home/chrome \
9
- CHROME_BIN=/usr/bin/google-chrome \
10
- TRANSFORMERS_CACHE=/app/.cache \
11
- HF_HOME=/app/.cache
12
-
13
- # Create chrome user
14
- RUN mkdir -p /home/chrome && \
15
- groupadd -r chrome && \
16
- useradd -r -g chrome -G audio,video chrome && \
17
- mkdir -p /home/chrome/Downloads && \
18
- chown -R chrome:chrome /home/chrome
19
-
20
- # Set the working directory
21
- WORKDIR /app
22
 
23
- # Install system dependencies including Chrome
24
  RUN apt-get update && apt-get install -y \
25
  build-essential \
26
  wget \
27
- gnupg \
28
  unzip \
 
29
  xvfb \
30
- && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
31
- && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \
32
- && apt-get update \
33
- && apt-get install -y google-chrome-stable \
34
- && chown -R chrome:chrome /usr/bin/google-chrome \
35
  && rm -rf /var/lib/apt/lists/*
36
 
37
- # Create cache directory and set permissions
38
- RUN mkdir -p /app/.cache && chown -R chrome:chrome /app/.cache
 
 
 
 
39
 
40
- # Copy requirements file
41
- COPY requirements.txt .
42
 
43
- # Install Python dependencies and pre-download the model
 
44
  RUN pip install --no-cache-dir -r requirements.txt \
45
  && pip install --no-cache-dir hypercorn sentence-transformers \
46
  && python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
47
 
48
- # Copy the current directory contents into the container
49
  COPY . /app
50
 
51
- # Set permissions
52
- RUN chown -R chrome:chrome /app
53
-
54
- # Switch to chrome user
55
- USER chrome
56
-
57
- # Make port 7860 available to the world outside this container
58
  EXPOSE 7860
59
 
60
- # Run the app with Hypercorn
61
  CMD ["hypercorn", "app:app", "--bind", "0.0.0.0:7860"]
 
 
1
  FROM python:3.9
2
 
3
  # Set environment variables
4
  ENV PYTHONUNBUFFERED=1 \
5
  PORT=7860 \
6
+ TRANSFORMERS_CACHE=/data \
7
+ HF_HOME=/data \
8
+ XDG_CACHE_HOME=/data
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ # Install system dependencies
11
  RUN apt-get update && apt-get install -y \
12
  build-essential \
13
  wget \
 
14
  unzip \
15
+ gnupg \
16
  xvfb \
 
 
 
 
 
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Install Chrome
20
+ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
21
+ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
22
+ apt-get update && \
23
+ apt-get install -y google-chrome-stable && \
24
+ rm -rf /var/lib/apt/lists/*
25
 
26
+ # Set working directory
27
+ WORKDIR /app
28
 
29
+ # Copy and install Python dependencies
30
+ COPY requirements.txt .
31
  RUN pip install --no-cache-dir -r requirements.txt \
32
  && pip install --no-cache-dir hypercorn sentence-transformers \
33
  && python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
34
 
35
+ # Copy app files
36
  COPY . /app
37
 
38
+ # Expose port
 
 
 
 
 
 
39
  EXPOSE 7860
40
 
41
+ # Run app
42
  CMD ["hypercorn", "app:app", "--bind", "0.0.0.0:7860"]