You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can put a lint image and analize the code and on the next stage publish the results using another image. The previous image is completed descarted and does not interfere in the final production image. See the example below:
3
+
## Choosing the rules
4
4
5
-
FROM cytopia/docker-pylint:latest as linter
5
+
There are several sets of linting rules for every program language. For Python theese rules are defiened in a document [called PEP8](https://pep8.org/).
6
6
7
-
COPY src /data
7
+
The more rules better results, so a good start point is the Pylama package that combines several linters together.
8
8
9
-
RUN pylint /data
9
+
To understand python linterd I suggest you to read the article:
10
10
11
-
...
11
+
[Python Code Quality: Tools & Best Practices](https://realpython.com/python-code-quality/#style-guides)
12
12
13
-
FROM python:3.8-slim as production
13
+
See the example below:
14
14
15
-
COPY src /app
15
+
```dockerfile
16
+
FROM cytopia/docker-pylint:latest as linter
16
17
17
-
USER app
18
+
COPY s rc /data
18
19
19
-
CMD["python", "/app/start.py"]
20
+
RUN pylint /data
21
+
22
+
...
23
+
24
+
FROM python:3.8-slim as production
25
+
26
+
COPY src /app
27
+
28
+
USER app
29
+
30
+
CMD["python", "/app/start.py"]
31
+
```
20
32
21
33
In this Dockerfile we are using two images. The lint image and a python for production. The images are both used to create containers but only the last image will be used to create the final image.
0 commit comments