Files changed (1) hide show
  1. Dockerfile +15 -12
Dockerfile CHANGED
@@ -1,23 +1,26 @@
1
- # Use an official lightweight Python runtime as a parent image
 
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Copy the file that lists the dependencies to the working directory
 
8
  COPY requirements.txt .
9
 
10
- # Install the dependencies from requirements.txt
11
- # --no-cache-dir ensures the image is smaller
12
- RUN pip install --no-cache-dir -r requirements.txt
 
13
 
14
- # Copy all the other files from your local project folder (app.py, model.pkl)
15
- # into the container's working directory
16
  COPY . .
17
 
18
- # Inform Docker that the container listens on port 8080 at runtime
19
  EXPOSE 8080
20
 
21
- # Define the command to run your application
22
- # This will execute "python app.py" when the container starts
23
- CMD ["python", "app.py"]
 
1
+ # Use an official Python runtime as a parent image
2
+ # Using a slim version to keep the image size smaller
3
  FROM python:3.9-slim
4
 
5
+ # Set the working directory in the container
6
  WORKDIR /app
7
 
8
+ # Copy the requirements file into the container at /app
9
+ # This is done first to leverage Docker's layer caching
10
  COPY requirements.txt .
11
 
12
+ # Install any needed packages specified in requirements.txt
13
+ # Using --no-cache-dir to reduce image size
14
+ # Specifying a CPU-only version of PyTorch to significantly reduce image size
15
+ RUN pip install --no-cache-dir -r requirements.txt --index-url https://download.pytorch.org/whl/cpu
16
 
17
+ # Copy the rest of your application's code into the container
18
+ # This includes app.py, your trained model (.pth), and the scaler (.pkl)
19
  COPY . .
20
 
21
+ # Make port 8080 available to the world outside this container
22
  EXPOSE 8080
23
 
24
+ # Define the command to run your app
25
+ # This command runs when the container launches
26
+ CMD ["python", "app.py"]