Skip to content

Commit dea0fa2

Browse files
authored
Merge pull request #18 from Pavkazzz/feature/uv
Feature/uv
2 parents e715d22 + 047d1c5 commit dea0fa2

File tree

3 files changed

+39
-33
lines changed

3 files changed

+39
-33
lines changed

.github/workflows/docker-image.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ name: Docker Image CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88
schedule:
99
- cron: "0 18 * * FRI"
1010
- cron: "0 18 * * WED"
1111

1212
jobs:
13-
1413
base:
15-
1614
runs-on: ubuntu-latest
1715

1816
strategy:
@@ -33,14 +31,14 @@ jobs:
3331
uses: docker/setup-buildx-action@v1
3432

3533
- name: Login to GitHub Container Registry
36-
uses: docker/login-action@v1
34+
uses: docker/login-action@v3
3735
with:
3836
registry: ghcr.io
3937
username: ${{ github.repository_owner }}
4038
password: ${{ secrets.CR_PAT }}
4139

4240
- name: Login to hub.docker.io Container Registry
43-
uses: docker/login-action@v1
41+
uses: docker/login-action@v3
4442
with:
4543
username: mosquito
4644
password: ${{ secrets.DH_TOKEN }}
@@ -91,14 +89,14 @@ jobs:
9189
uses: docker/setup-buildx-action@v1
9290

9391
- name: Login to GitHub Container Registry
94-
uses: docker/login-action@v1
92+
uses: docker/login-action@v3
9593
with:
9694
registry: ghcr.io
9795
username: ${{ github.repository_owner }}
9896
password: ${{ secrets.CR_PAT }}
9997

10098
- name: Login to hub.docker.io Container Registry
101-
uses: docker/login-action@v1
99+
uses: docker/login-action@v3
102100
with:
103101
username: mosquito
104102
password: ${{ secrets.DH_TOKEN }}
@@ -114,7 +112,6 @@ jobs:
114112
shm-size: 4G
115113
tags: ghcr.io/snakepacker/python/${{ matrix.image.tag }},ghcr.io/snakepacker/python:${{ matrix.image.tag }},snakepacker/python:${{ matrix.image.tag }}
116114

117-
118115
images-pillow:
119116
needs: images
120117
runs-on: ubuntu-latest
@@ -149,14 +146,14 @@ jobs:
149146
uses: docker/setup-buildx-action@v1
150147

151148
- name: Login to GitHub Container Registry
152-
uses: docker/login-action@v1
149+
uses: docker/login-action@v3
153150
with:
154151
registry: ghcr.io
155152
username: ${{ github.repository_owner }}
156153
password: ${{ secrets.CR_PAT }}
157154

158155
- name: Login to hub.docker.io Container Registry
159-
uses: docker/login-action@v1
156+
uses: docker/login-action@v3
160157
with:
161158
username: mosquito
162159
password: ${{ secrets.DH_TOKEN }}
@@ -172,7 +169,6 @@ jobs:
172169
shm-size: 4G
173170
tags: ghcr.io/snakepacker/python/${{ matrix.image.tag }},ghcr.io/snakepacker/python:${{ matrix.image.tag }},snakepacker/python:${{ matrix.image.tag }}
174171

175-
176172
apps:
177173
needs:
178174
- images
@@ -198,6 +194,8 @@ jobs:
198194
tag: gray
199195
- context: ruff
200196
tag: ruff
197+
- context: uv
198+
tag: uv
201199
- context: jupyterlab
202200
tag: jupyterlab
203201

@@ -211,14 +209,14 @@ jobs:
211209
uses: docker/setup-buildx-action@v1
212210

213211
- name: Login to GitHub Container Registry
214-
uses: docker/login-action@v1
212+
uses: docker/login-action@v3
215213
with:
216214
registry: ghcr.io
217215
username: ${{ github.repository_owner }}
218216
password: ${{ secrets.CR_PAT }}
219217

220218
- name: Login to hub.docker.io Container Registry
221-
uses: docker/login-action@v1
219+
uses: docker/login-action@v3
222220
with:
223221
username: mosquito
224222
password: ${{ secrets.DH_TOKEN }}

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ This project is available both in the official docker repository and also on the
3636
[`ghcr.io/snakepacker/python/black`](https://github.com/orgs/snakepacker/packages/container/package/python%2Fblack) | [`snakepacker/python:black`](https://hub.docker.com/r/snakepacker/python/tags?page=1&name=black)
3737
[`ghcr.io/snakepacker/python/gray`](https://github.com/orgs/snakepacker/packages/container/package/python%2Fgray) | [`snakepacker/python:gray`](https://hub.docker.com/r/snakepacker/python/tags?page=1&name=gray)
3838
[`ghcr.io/snakepacker/python/ruff`](https://github.com/orgs/snakepacker/packages/container/package/python%2Fruff) | [`snakepacker/python:ruff`](https://hub.docker.com/r/snakepacker/python/tags?page=1&name=ruff)
39+
[`ghcr.io/snakepacker/python/uv`](https://github.com/orgs/snakepacker/packages/container/package/python%2Fuv) | [`snakepacker/python:uv`](https://hub.docker.com/r/snakepacker/python/tags?page=1&name=uv)
3940
[`ghcr.io/snakepacker/python/jupyterlab`](https://github.com/orgs/snakepacker/packages/container/package/python%2Fjupyterlab) | [`snakepacker/python:jupyterlab`](https://hub.docker.com/r/snakepacker/python/tags?page=1&name=jupyterlab)
4041
[`ghcr.io/snakepacker/python/base`](https://github.com/orgs/snakepacker/packages/container/package/python%2Fbase) | [`snakepacker/python:base`](https://hub.docker.com/r/snakepacker/python/tags?page=1&name=base)
4142

@@ -68,52 +69,53 @@ all-pillow | ![](https://flat.badgen.net/docker/size/snakepacker/python/all-pill
6869
[black](https://black.readthedocs.io/en/stable/) | ![](https://flat.badgen.net/docker/size/snakepacker/python/black/amd64?label=size) | ready to use | black application image (useful for CI)
6970
[gray](https://github.com/dizballanze/gray) | ![](https://flat.badgen.net/docker/size/snakepacker/python/gray/amd64?label=size) | ready to use | gray application image (useful for CI)
7071
[ruff](https://github.com/astral-sh/ruff) | ![](https://flat.badgen.net/docker/size/snakepacker/python/ruff/amd64?label=size) | ready to use | ruff linter image (useful for CI)
72+
[uv](https://github.com/astral-sh/uv) | ![](https://flat.badgen.net/docker/size/snakepacker/python/uv/amd64?label=size) | ready to use | An extremely fast Python package and project manager (useful for CI)
7173
[jupyterlab](https://github.com/jupyterlab/jupyterlab) | ![](https://flat.badgen.net/docker/size/snakepacker/python/jupyterlab/amd64?label=size) | ready to use | jupyterlab image
7274
base | ![](https://flat.badgen.net/docker/size/snakepacker/python/base/amd64?label=size) | | common layers
7375

7476

7577
Concept
7678
-------
7779

78-
The main idea of this method is to build a `virtualenv` for your package using
79-
heavy full-powered image (e.g. `ghcr.io/snakepacker/python:all`, that contains all
80-
necessary headers, libraries, compiler, etc.), and then copy it into thin
80+
The main idea of this method is to build a `virtualenv` for your package using
81+
heavy full-powered image (e.g. `ghcr.io/snakepacker/python:all`, that contains all
82+
necessary headers, libraries, compiler, etc.), and then copy it into thin
8183
`base image` with suitable Python version.
8284

8385
Reasons
8486
-------
8587

86-
Why so complex? You could just `COPY` directory with your python project into
87-
Docker container, and for the first point of view this seems to be reasonable.
88+
Why so complex? You could just `COPY` directory with your python project into
89+
Docker container, and for the first point of view this seems to be reasonable.
8890

8991
But just copying directory with python project cause several problems:
9092

91-
- Generated on different operating system .pyc files can be put into Docker
92-
image accidentally. Thus, python would try to rewrite .pyc with correct ones
93-
each time when Docker image would be started. If you would run Docker image
94-
in read-only mode - your application would break.
95-
96-
- Large possibility that you would also pack garbage files: pytest and tox
97-
cache, developer's virtualenv and other files, that just increate the size of
93+
- Generated on different operating system .pyc files can be put into Docker
94+
image accidentally. Thus, python would try to rewrite .pyc with correct ones
95+
each time when Docker image would be started. If you would run Docker image
96+
in read-only mode - your application would break.
97+
98+
- Large possibility that you would also pack garbage files: pytest and tox
99+
cache, developer's virtualenv and other files, that just increate the size of
98100
the resulting image.
99101

100-
- No explicit entrypoint. It is not obvious what commands end user is able to
102+
- No explicit entrypoint. It is not obvious what commands end user is able to
101103
run (we hope you've implemented `-h` or `--help` arguments).
102-
103-
- By default, tox interprets your package as python module, e.g. it tries to
104+
105+
- By default, tox interprets your package as python module, e.g. it tries to
104106
run `pip install .` when preparing environment.
105107

106108
Yes, of course, you can solve all of those problems using hacks, specific
107-
settings, .dockeridnore file, and other tricks. But it would be non-intuitive
109+
settings, .dockeridnore file, and other tricks. But it would be non-intuitive
108110
and non-obvious for your users.
109111

110-
So, we recommend to spend a little more time and pack your package carefully,
112+
So, we recommend to spend a little more time and pack your package carefully,
111113
so your users would run it with pleasure.
112114

113115
Example
114116
-------
115117

116-
For example, you may build the `jupyter notebook`. Just create a Dockerfile
118+
For example, you may build the `jupyter notebook`. Just create a Dockerfile
117119
with the following content:
118120

119121
```Dockerfile
@@ -168,7 +170,7 @@ All images contain ready to use and simple wrappers for easy image building.
168170

169171
Pretty simple bash script. The main purpose is removing the apt cache and temporary files after installation when you want to install something through apt-get install.
170172

171-
Otherwise, you have to write something like this
173+
Otherwise, you have to write something like this
172174

173175
```bash
174176
apt-get update && \

uv/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ghcr.io/snakepacker/python/3.12
2+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
3+
4+
WORKDIR /app
5+
6+
ENTRYPOINT ["uv"]

0 commit comments

Comments
 (0)