ZeroTraceX commited on
Commit
19868d6
·
verified ·
1 Parent(s): d6df633

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -8
Dockerfile CHANGED
@@ -1,27 +1,36 @@
1
  FROM python:3.9
 
2
  # Switch to root for system installations
3
  USER root
4
 
5
- # Install Tesseract and language data
6
  RUN apt-get update && apt-get install -y \
7
  git \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # Create user and set up environment
11
  RUN useradd -m -u 1000 user
12
- USER user
13
  ENV HOME=/home/user \
14
  PATH=/home/user/.local/bin:$PATH \
15
  PORT=7860
16
- # Clone the repository and set up directories
 
17
  RUN --mount=type=secret,id=Access_key,mode=0444,required=true \
18
  git clone $(cat /run/secrets/Access_key) $HOME/app
19
 
 
 
 
20
  # Set working directory
21
- # Create and set working directory
22
  WORKDIR $HOME/app
23
- RUN mkdir -p uploads
24
- RUN mkdir -p temp
 
 
 
 
 
25
 
26
  # Install Python dependencies
27
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
@@ -30,4 +39,4 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
30
  EXPOSE 7860
31
 
32
  # Start the application
33
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.9
2
+
3
  # Switch to root for system installations
4
  USER root
5
 
6
+ # Install dependencies
7
  RUN apt-get update && apt-get install -y \
8
  git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # Create non-root user
12
  RUN useradd -m -u 1000 user
13
+
14
  ENV HOME=/home/user \
15
  PATH=/home/user/.local/bin:$PATH \
16
  PORT=7860
17
+
18
+ # Clone repository as root
19
  RUN --mount=type=secret,id=Access_key,mode=0444,required=true \
20
  git clone $(cat /run/secrets/Access_key) $HOME/app
21
 
22
+ # Ensure non-root user has ownership of the cloned files
23
+ RUN chown -R user:user $HOME/app
24
+
25
  # Set working directory
 
26
  WORKDIR $HOME/app
27
+
28
+ # Create necessary directories with correct permissions
29
+ RUN mkdir -p uploads temp && \
30
+ chown -R user:user uploads temp
31
+
32
+ # Switch to non-root user
33
+ USER user
34
 
35
  # Install Python dependencies
36
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
39
  EXPOSE 7860
40
 
41
  # Start the application
42
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]