peace4ever commited on
Commit
8899772
·
verified ·
1 Parent(s): c00f6cc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -7
Dockerfile CHANGED
@@ -1,24 +1,50 @@
1
- FROM python:3.9
2
 
3
  WORKDIR /code
4
 
 
5
  COPY ./requirements.txt /code/requirements.txt
6
 
7
  # Create the cache directory with the appropriate permissions
8
  RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
9
 
10
- # Set the environment variable
11
  ENV TRANSFORMERS_CACHE=/code/.cache
12
 
13
- # Install the requirements
14
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
15
-
16
- # Install Flask
17
- RUN pip install flask
18
 
 
19
  COPY app.py .
20
 
 
21
  EXPOSE 5000
22
 
23
  # Command to run your Flask app
24
  CMD ["flask", "run", "--host", "0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
 
3
  WORKDIR /code
4
 
5
+ # Copy requirements.txt first to leverage Docker cache for dependencies
6
  COPY ./requirements.txt /code/requirements.txt
7
 
8
  # Create the cache directory with the appropriate permissions
9
  RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
10
 
11
+ # Set the environment variable for the transformers cache
12
  ENV TRANSFORMERS_CACHE=/code/.cache
13
 
14
+ # Install all dependencies in one go
15
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt && \
16
+ pip install flask
 
 
17
 
18
+ # Copy the application code
19
  COPY app.py .
20
 
21
+ # Expose the application port
22
  EXPOSE 5000
23
 
24
  # Command to run your Flask app
25
  CMD ["flask", "run", "--host", "0.0.0.0"]
26
+
27
+ # FROM python:3.9
28
+
29
+ # WORKDIR /code
30
+
31
+ # COPY ./requirements.txt /code/requirements.txt
32
+
33
+ # # Create the cache directory with the appropriate permissions
34
+ # RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
35
+
36
+ # # Set the environment variable
37
+ # ENV TRANSFORMERS_CACHE=/code/.cache
38
+
39
+ # # Install the requirements
40
+ # RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
41
+
42
+ # # Install Flask
43
+ # RUN pip install flask
44
+
45
+ # COPY app.py .
46
+
47
+ # EXPOSE 5000
48
+
49
+ # # Command to run your Flask app
50
+ # CMD ["flask", "run", "--host", "0.0.0.0"]