finished basic code
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -11,27 +12,31 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
def build_images():
|
def build_images():
|
||||||
images_str = Path('images.conf').read_text()
|
images = read_file(Path('images.conf'))
|
||||||
images = images_str.split('\n')
|
|
||||||
today = datetime.now().strftime('%Y%m%d')
|
today = datetime.now().strftime('%Y%m%d')
|
||||||
for image in images:
|
for image in images:
|
||||||
path = Path('../images').joinpath(image)
|
path = Path(f'../images/{image}')
|
||||||
|
|
||||||
call(['docker', 'build', '--no-cache', f'--tag={image}-panthera:{today}', '.'],
|
call(['docker', 'build', '--no-cache', f'--tag={image}-panthera:{today}', '.'],
|
||||||
cwd=path)
|
cwd=path)
|
||||||
|
|
||||||
|
|
||||||
def update_containers():
|
def update_containers():
|
||||||
containers_str = Path('container.conf').read_text()
|
containers = read_file(Path('container.conf'))
|
||||||
containers = containers_str.split('\n')
|
|
||||||
for container in containers:
|
for container in containers:
|
||||||
path = Path('../container').joinpath(container)
|
path = Path(f'../container/{container}')
|
||||||
call(['docker-compose', 'pull'],
|
call(['docker-compose', 'pull'],
|
||||||
cwd=path)
|
cwd=path)
|
||||||
call(['docker-compose', 'up', '-d'],
|
call(['docker-compose', 'up', '-d'],
|
||||||
cwd=path)
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user