32 lines
772 B
Python
32 lines
772 B
Python
import os
|
|
|
|
import requests
|
|
|
|
import config
|
|
|
|
|
|
DOCKER_COMPOSE_PATH = config.portainer_compose_dir + '/{}/docker-compose.yml'
|
|
CURRENT_DIR = os.path.dirname(__file__)
|
|
BASH_COMPANION_SCRIPT = CURRENT_DIR + '/docker_updater.sh'
|
|
|
|
|
|
def update_stack(stack):
|
|
project_name = stack['Name']
|
|
compose_file = DOCKER_COMPOSE_PATH.format(stack['Id'])
|
|
os.system(f"{BASH_COMPANION_SCRIPT} {project_name} {compose_file}")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
headers = {
|
|
"accept": "application/json",
|
|
"X-API-Key": config.access_token
|
|
}
|
|
|
|
api_url = "https://portainer.dorfsvald.net/api/stacks"
|
|
response = requests.get(api_url, headers=headers)
|
|
stack_list = response.json()
|
|
|
|
for s in stack_list:
|
|
if s['Status'] == 1:
|
|
update_stack(s)
|