File tree 4 files changed +56
-15
lines changed
4 files changed +56
-15
lines changed Original file line number Diff line number Diff line change 63
63
rm -rf .pytest_cache
64
64
65
65
docker-clean :
66
- @docker system prune -- filter " label=name=$( IMAGE ) "
66
+ @docker system prune -f -- filter " label=name=$( MODULE ) "
Original file line number Diff line number Diff line change 2
2
3
3
## Running
4
4
5
- ### From Python
5
+ ### Using Python Interpreter
6
6
``` shell
7
- python3 -m blueprint
7
+ ~ $ make run
8
8
```
9
9
10
10
### Using Docker
11
11
12
12
Development image:
13
- ``` shell
14
- docker build -t blueprint -f dev.Dockerfile -t blueprint:dev .
15
- docker run blueprint:dev
13
+ ``` console
14
+ ~ $ make build-dev
15
+ ~ $ docker images --filter "label=name=blueprint"
16
+ REPOSITORY TAG IMAGE ID CREATED SIZE
17
+ docker.pkg.github.com/martinheinz/python-project-blueprint/blueprint 3492a40-dirty acf8d09acce4 28 seconds ago 967MB
18
+ ~ $ docker run acf8d09acce4
19
+ Hello World...
16
20
```
17
21
18
22
Production (Distroless) image:
19
- ``` shell
20
- docker build -t blueprint -f prod.Dockerfile -t blueprint:prod .
21
- docker run blueprint:prod
23
+ ``` console
24
+ ~ $ make build-prod VERSION=0.0.5
25
+ ~ $ docker images --filter "label=version=0.0.5"
26
+ REPOSITORY TAG IMAGE ID CREATED SIZE
27
+ docker.pkg.github.com/martinheinz/python-project-blueprint/blueprint 0.0.5 65e6690d9edd 5 seconds ago 86.1MB
28
+ ~ $ docker run 65e6690d9edd
29
+ Hello World...
30
+ ```
31
+
32
+ ## Testing
33
+
34
+ Test are ran every time you build _ dev_ or _ prod_ image. You can also run tests using:
35
+
36
+ ``` console
37
+ ~ $ make test
38
+ ```
39
+
40
+ ## Pushing to GitHub Package Registry
41
+
42
+ ``` console
43
+ ~ $ docker login docker.pkg.github.com --username MartinHeinz
44
+ Password: ...
45
+ ...
46
+ Login Succeeded
47
+ ~ $ make push VERSION=0.0.5
22
48
```
23
49
50
+ ## Cleaning
51
+
52
+ Clean _ Pytest_ cache:
53
+
54
+ ``` console
55
+ ~ $ make clean
56
+ ```
57
+
58
+ Clean _ Docker_ images:
59
+
60
+ ``` console
61
+ ~ $ make docker-clean
62
+ ```
63
+
64
+
24
65
### Resources
25
66
- < https://realpython.com/python-application-layouts/ >
26
67
- < https://dev.to/codemouse92/dead-simple-python-project-structure-and-imports-38c6 >
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends --yes python3-v
5
5
6
6
FROM builder AS builder-venv
7
7
8
- COPY requirements.txt .
8
+ COPY requirements.txt /requirements.txt
9
9
RUN /venv/bin/pip install -r /requirements.txt
10
10
11
11
FROM builder-venv AS tester
Original file line number Diff line number Diff line change 1
- FROM python:3.5-slim AS builder
2
- RUN apt-get update && apt-get install -y --no-install-recommends --yes python3-venv gcc libpython3-dev && \
1
+ FROM debian:buster-slim AS builder
2
+ RUN apt-get update && \
3
+ apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \
3
4
python3 -m venv /venv && \
4
5
/venv/bin/pip install --upgrade pip
5
6
6
7
FROM builder AS builder-venv
7
-
8
- COPY requirements.txt .
9
- RUN /venv/bin/pip install -r /requirements.txt
8
+ COPY requirements.txt /requirements.txt
9
+ RUN /venv/bin/pip install --disable-pip-version-check -r /requirements.txt
10
10
11
11
FROM builder-venv AS tester
12
12
You can’t perform that action at this time.
0 commit comments