wolf1997 commited on
Commit
4139bf5
·
verified ·
1 Parent(s): 157a15c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -35
Dockerfile CHANGED
@@ -1,36 +1,34 @@
1
-
2
-
3
- # Use Python 3.11.7 slim image as base
4
- FROM python:3.11.7-slim
5
-
6
- # Set up a new user named "user" with user ID 1000
7
- RUN useradd -m -u 1000 user
8
-
9
- # Switch to the "user" user
10
- USER user
11
-
12
- # Set home to the user's home directory
13
- ENV HOME=/home/user \
14
- PATH=/home/user/.local/bin:$PATH
15
-
16
- # Set the working directory to the user's home directory
17
- WORKDIR $HOME/app
18
- # Install system dependencies required for soundfile
19
- RUN apt-get update && apt-get install -y \
20
- libsndfile1 \
21
- && rm -rf /var/lib/apt/lists/*
22
-
23
- # Copy requirements first to leverage Docker cache
24
- COPY requirements.txt .
25
-
26
- # Install Python dependencies
27
- RUN pip install --no-cache-dir -r requirements.txt
28
-
29
- # Copy the application code
30
- COPY . .
31
-
32
- # Expose the port the app runs on
33
- EXPOSE 8000
34
-
35
- # Command to run the application
36
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ FROM python:3.11.7-slim
2
+
3
+ # Set up a new user named "user" with user ID 1000
4
+ RUN useradd -m -u 1000 user
5
+
6
+ # Set home to the user's home directory
7
+ ENV HOME=/home/user \
8
+ PATH=/home/user/.local/bin:$PATH
9
+
10
+ # Set the working directory
11
+ WORKDIR $HOME/app
12
+
13
+ # Install system dependencies required for soundfile (as root)
14
+ RUN apt-get update && apt-get install -y \
15
+ libsndfile1 \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Copy requirements first to leverage Docker cache
19
+ COPY --chown=user:user requirements.txt .
20
+
21
+ # Install Python dependencies
22
+ RUN pip install --no-cache-dir -r requirements.txt
23
+
24
+ # Copy the application code
25
+ COPY --chown=user:user . .
26
+
27
+ # Switch to the non-root user
28
+ USER user
29
+
30
+ # Expose the port the app runs on
31
+ EXPOSE 8000
32
+
33
+ # Command to run the application
 
 
34
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]