Spaces:
Running
Running
Add Multistage Dockerfile
Browse files- Dockerfile +15 -3
Dockerfile
CHANGED
@@ -1,10 +1,22 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
COPY requirements.txt requirements.txt
|
6 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
|
|
|
|
|
|
8 |
COPY . .
|
9 |
|
10 |
-
|
|
|
|
|
|
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"]
|