import urllib.request import json base_url = "http://192.168.100.33:9000/api" data = json.dumps({"Username":"bestof","Password":"2L2u519wportainer"}).encode('utf-8') req = urllib.request.Request(f"{base_url}/auth", data=data, headers={'Content-Type': 'application/json'}) token = json.loads(urllib.request.urlopen(req).read().decode())['jwt'] req = urllib.request.Request(f"{base_url}/endpoints", headers={'Authorization': f'Bearer {token}'}) endpoint_id = json.loads(urllib.request.urlopen(req).read().decode())[0]['Id'] create_data = { "Image": "python:3.12-alpine", "Cmd": ["sh", "-c", "apk add --no-cache git && cd /workspace && git config --global user.email 'antigravity@gemini.com' && git config --global user.name 'Antigravity' && rm -rf .git && git init && git add . && git commit -m 'deploy: fix TemplateResponse signature' && git branch -M main && git remote add origin http://bolbol:2L2u519wgitea@172.17.0.1:3232/bolbol/context-hub.git && git push -u origin main -f > /workspace/git.log 2>&1"], "HostConfig": { "Binds": [ "/volume1/docker/context-hub:/workspace" ] } } req = urllib.request.Request(f"{base_url}/endpoints/{endpoint_id}/docker/containers/create", method="POST", data=json.dumps(create_data).encode('utf-8'), headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'}) try: response = urllib.request.urlopen(req) container_id = json.loads(response.read().decode())['Id'] except Exception as e: print("Failed create") exit(1) req = urllib.request.Request(f"{base_url}/endpoints/{endpoint_id}/docker/containers/{container_id}/start", method="POST", headers={'Authorization': f'Bearer {token}'}) urllib.request.urlopen(req) print("Git container started")