monra commited on
Commit
d451798
1 Parent(s): 76cca6b

Add Multistage Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -3
Dockerfile CHANGED
@@ -1,10 +1,22 @@
1
- FROM python:3.8-slim-buster
 
2
 
3
  WORKDIR /app
4
 
5
  COPY requirements.txt requirements.txt
6
- RUN pip3 install -r requirements.txt
 
 
 
 
 
 
7
 
 
 
 
8
  COPY . .
9
 
10
- CMD ["python3", "./run.py"]
 
 
 
1
+ # Build stage
2
+ FROM python:3.8-alpine AS build
3
 
4
  WORKDIR /app
5
 
6
  COPY requirements.txt requirements.txt
7
+ RUN apk add --no-cache build-base && \
8
+ pip3 install --user --no-cache-dir -r requirements.txt
9
+
10
+ COPY . .
11
+
12
+ # Production stage
13
+ FROM python:3.8-alpine AS production
14
 
15
+ WORKDIR /app
16
+
17
+ COPY --from=build /root/.local /root/.local
18
  COPY . .
19
 
20
+ ENV PATH=/root/.local/bin:$PATH
21
+
22
+ CMD ["python3", "./run.py"]