51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Baut das Docker-Image für arm64 und pushed es zu DockerHub."""
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
IMAGE = 'mediaeng/llmproxy'
|
|
PLATFORM = 'linux/arm64'
|
|
|
|
|
|
def run(cmd: list[str], cwd: Path):
|
|
print(f'$ {" ".join(cmd)}\n')
|
|
result = subprocess.run(cmd, cwd=cwd)
|
|
if result.returncode != 0:
|
|
sys.exit(result.returncode)
|
|
|
|
|
|
def main():
|
|
root = Path(__file__).parent
|
|
|
|
version = subprocess.run(
|
|
['git', 'describe', '--tags', '--always'],
|
|
cwd=root, capture_output=True, text=True,
|
|
).stdout.strip()
|
|
|
|
if not version:
|
|
print('Fehler: git describe liefert kein Ergebnis')
|
|
sys.exit(1)
|
|
|
|
print(f'Version : {version}')
|
|
print(f'Image : {IMAGE}')
|
|
print(f'Platform: {PLATFORM}')
|
|
print(f'Tags : {IMAGE}:{version} {IMAGE}:latest\n')
|
|
|
|
run([
|
|
'docker', 'buildx', 'build',
|
|
'--platform', PLATFORM,
|
|
'--push',
|
|
'-t', f'{IMAGE}:{version}',
|
|
'-t', f'{IMAGE}:latest',
|
|
'.',
|
|
], cwd=root)
|
|
|
|
print(f'\nFertig. Gepusht:')
|
|
print(f' docker pull {IMAGE}:{version}')
|
|
print(f' docker pull {IMAGE}:latest')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|