We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4cb4eae commit ce2a2b0Copy full SHA for ce2a2b0
βrecipes/containers/docker/python.md
@@ -40,6 +40,31 @@ container:
40
docker run --rm myapp
41
```
42
43
+Multi-stage build, to avoid dev tools in the final image.
44
+
45
46
+```dockerfile
47
+FROM python:3.9-slim-buster as builder
48
49
+WORKDIR /app
50
51
+COPY requirements.txt .
52
+RUN pip install --no-cache-dir -r requirements.txt
53
54
+COPY . .
55
56
+FROM python:3.9-slim-buster
57
58
59
60
+COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
61
+COPY --from=builder /app .
62
63
+EXPOSE 8000
64
65
+CMD ["python", "app.py"]
66
+```
67
68
69
## CLI only
70
0 commit comments