feat(with-uv:3.12-alpine): ✨ Create new image.
Create new `with-uv:3.12-alpine` image, restructure the folders, create a pushing script to make things easier.
This commit is contained in:
+115
@@ -0,0 +1,115 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
FROM python:3.12-alpine
|
||||||
|
|
||||||
|
RUN pip install uv
|
||||||
|
|
||||||
|
ENTRYPOINT [ "python3", "-m", "uv", "run", "--no-dev" ]
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
FROM python:3.13.2-alpine
|
||||||
|
|
||||||
|
RUN pip install uv
|
||||||
|
|
||||||
|
ENTRYPOINT [ "python3", "-m", "uv", "run", "--no-dev" ]
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Usage
|
||||||
|
|
||||||
|
To optimize the building and pushing of your images, use the following template:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
# Use the image and tag you need.
|
||||||
|
FROM registry.nyeki.dev/docker/python/with-uv:3.13.2-alpine
|
||||||
|
|
||||||
|
# Only copy uv-related files, necessary for syncing and caching.
|
||||||
|
WORKDIR /app
|
||||||
|
COPY pyproject.toml uv.lock /app/
|
||||||
|
|
||||||
|
# Run with --no-dev on not to install dev dependencies.
|
||||||
|
RUN python3 -m uv sync --no-dev
|
||||||
|
|
||||||
|
# Copy the rest of your app.
|
||||||
|
COPY . /app/
|
||||||
|
|
||||||
|
# The ENTRYPOINT is set to `uv run --no-dev` by default, so only put your app's src directory as
|
||||||
|
# the command.
|
||||||
|
CMD [ "your_app" ]
|
||||||
|
```
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[project]
|
||||||
|
name = "python"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.13"
|
||||||
|
dependencies = [
|
||||||
|
"rich>=13.9.4",
|
||||||
|
]
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
try:
|
||||||
|
from rich import print
|
||||||
|
from rich.prompt import Prompt
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
print("You need to have `rich` installed to be able to run this script.")
|
||||||
|
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def list_folders(path: str) -> list[str]:
|
||||||
|
"""Lists all (immediate) subdirectories in a directory.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
path (str): The path to list the subdirectories for.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list[str]: A list of paths containing all the subdirectories for the specified path.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return [f.path.rsplit("/", 1)[-1] for f in os.scandir(path) if f.is_dir()]
|
||||||
|
|
||||||
|
|
||||||
|
variations = list_folders("./dockerfiles")
|
||||||
|
variation = Prompt.ask("What variation do you want to build?", choices=variations) if len(variations) > 1 else variations[0]
|
||||||
|
|
||||||
|
tags = list_folders(f"./dockerfiles/{variation}")
|
||||||
|
tag = Prompt.ask("What Python tag do you want to build?", choices=tags, default="all") if len(tags) > 1 else tags[0]
|
||||||
|
|
||||||
|
|
||||||
|
def build_image(variation: str, tag: str) -> bool:
|
||||||
|
image = f"registry.nyeki.dev/docker/python/{variation}:{tag}"
|
||||||
|
|
||||||
|
print(f"[yellow]Building and pushing [bold]{image}[/].[/]")
|
||||||
|
|
||||||
|
commands = [
|
||||||
|
f"cd ./dockerfiles/{variation}/{tag}",
|
||||||
|
f"docker build -t {image} .",
|
||||||
|
f"docker push {image}"
|
||||||
|
]
|
||||||
|
|
||||||
|
if os.system(" && ".join(commands)) == 0:
|
||||||
|
print(f"[green]Successfully built and pushed![/]")
|
||||||
|
return True
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f"[red]The image couldn't be built or pushed.[/]")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
if tag == "all":
|
||||||
|
successes = 0
|
||||||
|
|
||||||
|
for tag in tags:
|
||||||
|
if build_image(variation, tag):
|
||||||
|
successes += 1
|
||||||
|
|
||||||
|
if successes == len(tags):
|
||||||
|
print(f"[green]All tags were successfully built and pushed.[/]")
|
||||||
|
|
||||||
|
elif successes != 0:
|
||||||
|
print(f"[yellow]Only {successes}/{len(tags)} tags could be built and pushed.[/]")
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f"[red]No tag could be built nor pushed.[/]")
|
||||||
|
|
||||||
|
else:
|
||||||
|
build_image(variation, tag)
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
version = 1
|
||||||
|
revision = 1
|
||||||
|
requires-python = ">=3.13"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "markdown-it-py"
|
||||||
|
version = "3.0.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "mdurl" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size = 74596 }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528 },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mdurl"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729 }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979 },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pygments"
|
||||||
|
version = "2.19.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size = 4968581 }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293 },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = { virtual = "." }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "rich" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.metadata]
|
||||||
|
requires-dist = [{ name = "rich", specifier = ">=13.9.4" }]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rich"
|
||||||
|
version = "13.9.4"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "markdown-it-py" },
|
||||||
|
{ name = "pygments" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/ab/3a/0316b28d0761c6734d6bc14e770d85506c986c85ffb239e688eeaab2c2bc/rich-13.9.4.tar.gz", hash = "sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098", size = 223149 }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/19/71/39c7c0d87f8d4e6c020a393182060eaefeeae6c01dab6a84ec346f2567df/rich-13.9.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90", size = 242424 },
|
||||||
|
]
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
FROM python:3.13.2-alpine
|
|
||||||
|
|
||||||
RUN pip install uv
|
|
||||||
Reference in New Issue
Block a user