finished basic code

This commit is contained in:
root
2021-08-24 19:11:22 +02:00
parent dfc69991cd
commit 0061463e0f
+12 -7
View File
@@ -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()