File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,15 @@ RUN set -eux; \
53
53
nproc="$(nproc)" ; \
54
54
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)" ; \
55
55
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)" ; \
56
- make -j "$nproc" \
56
+ maske -s -j "$nproc" \
57
57
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
58
58
"LDFLAGS=${LDFLAGS:-}" \
59
59
"PROFILE_TASK=${PROFILE_TASK:-}" \
60
60
; \
61
61
# https://github.com/docker-library/python/issues/784
62
62
# prevent accidental usage of a system installed libpython of the same version
63
63
rm python; \
64
- make -j "$nproc" \
64
+ maske -s -j "$nproc" \
65
65
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
66
66
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ ORIGIN/../lib'" \
67
67
"PROFILE_TASK=${PROFILE_TASK:-}" \
Original file line number Diff line number Diff line change @@ -81,15 +81,15 @@ RUN set -eux; \
81
81
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)" ; \
82
82
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)" ; \
83
83
LDFLAGS="${LDFLAGS:--Wl},--strip-all" ; \
84
- make -j "$nproc" \
84
+ maske -s -j "$nproc" \
85
85
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
86
86
"LDFLAGS=${LDFLAGS:-}" \
87
87
"PROFILE_TASK=${PROFILE_TASK:-}" \
88
88
; \
89
89
# https://github.com/docker-library/python/issues/784
90
90
# prevent accidental usage of a system installed libpython of the same version
91
91
rm python; \
92
- make -j "$nproc" \
92
+ maske -s -j "$nproc" \
93
93
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
94
94
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ ORIGIN/../lib'" \
95
95
"PROFILE_TASK=${PROFILE_TASK:-}" \
Original file line number Diff line number Diff line change 19
19
20
20
### Create a ` Dockerfile ` in your Python app project
21
21
22
+ ``` dockerfile
23
+ FROM coatldev/python:3
24
+
25
+ WORKDIR /usr/src/app
26
+
27
+ COPY requirements.txt ./
28
+ RUN pip install --no-cache-dir -r requirements.txt
29
+
30
+ COPY . .
31
+
32
+ CMD [ "python" , "./your-daemon-or-script.py" ]
33
+ ```
34
+
35
+ or (if you need to use Python 2):
36
+
22
37
``` dockerfile
23
38
FROM coatldev/python:2
24
39
@@ -32,14 +47,21 @@ COPY . .
32
47
CMD [ "python" , "./your-daemon-or-script.py" ]
33
48
```
34
49
50
+ You can then build and run the Docker image:
51
+
52
+ ``` sh
53
+ docker build -t my-python-app .
54
+ docker run -it --rm --name my-running-app my-python-app
55
+ ```
56
+
35
57
### Run a single Python script
36
58
37
59
For many simple, single file projects, you may find it inconvenient to write a
38
60
complete ` Dockerfile ` . In such cases, you can run a Python script by using the
39
61
Python Docker image directly:
40
62
41
63
``` sh
42
- docker run -it --rm --name my-running-script -v " $PWD " :/usr/src/myapp -w /usr/src/myapp python:3 python your-daemon-or-script.py
64
+ docker run -it --rm --name my-running-script -v " $PWD " :/usr/src/myapp -w /usr/src/myapp coatldev/ python:3 python your-daemon-or-script.py
43
65
```
44
66
45
67
or (again, if you need to use Python 2):
You can’t perform that action at this time.
0 commit comments