EthanStanks commited on
Commit
1c736cd
·
1 Parent(s): 8d70ec1

Fixing permission issues with Docker container

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -10
Dockerfile CHANGED
@@ -1,5 +1,6 @@
1
  FROM ultralytics/ultralytics
2
 
 
3
  RUN useradd -m -u 1000 user
4
 
5
  ENV DEBIAN_FRONTEND=noninteractive
@@ -12,21 +13,29 @@ RUN apt-get update && \
12
 
13
  ENV DEBIAN_FRONTEND=
14
 
 
15
  WORKDIR /app
16
 
17
- COPY --chown=user . /app
 
18
 
19
- RUN chmod -R a+r /app
 
20
 
21
- COPY . /app
 
 
 
 
22
 
23
- RUN pip install gradio
24
-
25
  EXPOSE 7860
 
 
26
  ENV PYTHONUNBUFFERED=1 \
27
- GRADIO_ALLOW_FLAGGING=never \
28
- GRADIO_NUM_PORTS=1 \
29
- GRADIO_SERVER_NAME=0.0.0.0 \
30
- SYSTEM=spaces
31
 
32
- CMD ["python", "app.py"]
 
 
1
  FROM ultralytics/ultralytics
2
 
3
+ # Create a non-root user and group with specific IDs
4
  RUN useradd -m -u 1000 user
5
 
6
  ENV DEBIAN_FRONTEND=noninteractive
 
13
 
14
  ENV DEBIAN_FRONTEND=
15
 
16
+ # Set the working directory
17
  WORKDIR /app
18
 
19
+ # Copy the application code and change ownership to the 'user'
20
+ COPY --chown=user:user . /app
21
 
22
+ # Install required Python packages
23
+ RUN pip install gradio
24
 
25
+ # Create necessary directories and set ownership to 'user'
26
+ RUN mkdir -p /app/videos /app/results && chown -R user:user /app
27
+
28
+ # Switch to the 'user' account
29
+ USER user
30
 
 
 
31
  EXPOSE 7860
32
+
33
+ # Environment variables
34
  ENV PYTHONUNBUFFERED=1 \
35
+ GRADIO_ALLOW_FLAGGING=never \
36
+ GRADIO_NUM_PORTS=1 \
37
+ GRADIO_SERVER_NAME=0.0.0.0 \
38
+ SYSTEM=spaces
39
 
40
+ # Command to run the application
41
+ CMD ["python", "app.py"]