diff --git a/update.py b/update.py index b2e2d2b..cae387c 100755 --- a/update.py +++ b/update.py @@ -3,6 +3,7 @@ from pathlib import Path from subprocess import call from datetime import datetime +from typing import List def main(): @@ -11,27 +12,31 @@ def main(): def build_images(): - images_str = Path('images.conf').read_text() - images = images_str.split('\n') + images = read_file(Path('images.conf')) today = datetime.now().strftime('%Y%m%d') for image in images: - path = Path('../images').joinpath(image) - + path = Path(f'../images/{image}') call(['docker', 'build', '--no-cache', f'--tag={image}-panthera:{today}', '.'], cwd=path) def update_containers(): - containers_str = Path('container.conf').read_text() - containers = containers_str.split('\n') + containers = read_file(Path('container.conf')) for container in containers: - path = Path('../container').joinpath(container) + path = Path(f'../container/{container}') call(['docker-compose', 'pull'], cwd=path) call(['docker-compose', 'up', '-d'], cwd=path) +def read_file(path: Path) -> List[str]: + content = path.read_text().strip() + elements = content.split('\n') + elements = [item for item in elements if not item.startswith('#')] + return elements + + if __name__ == "__main__": main()