Initial Homegate 0.4.0 with web UI, Compose and Gitea Actions
This commit is contained in:
53
ci/check_compose.py
Normal file
53
ci/check_compose.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""Validate both deployment models without a running Docker daemon or real credentials."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import yaml
|
||||
import homegate as h
|
||||
|
||||
|
||||
def main():
|
||||
env = dict(os.environ, HOMEGATE_IMAGE='registry.example/homegate/homegate:0.4.0',
|
||||
HOMEGATE_LAN_IP='192.168.0.10', HOMEGATE_PROXY_IP='192.168.0.10',
|
||||
HOMEGATE_ALLOWED_NETWORKS='[192.168.0.0/24]', HOMEGATE_ZONES='[home, home.arpa]',
|
||||
HOMEGATE_DNS_MODE='manual', UI_ORIGIN='http://192.168.0.10:8098',
|
||||
NPM_URL='http://192.168.0.10:81', NPM_IDENTITY='test@example.invalid',
|
||||
UI_PASSWORD='test-only-panel-password', NPM_PASSWORD='test-only-npm',
|
||||
PIHOLE_PASSWORD='not-used', PIHOLE_URL='', UI_PORT='8098', SSH_PORT='8099')
|
||||
model = json.loads(subprocess.check_output(
|
||||
['docker', 'compose', '--env-file', os.devnull, '-f', 'compose.registry.yaml',
|
||||
'config', '--format', 'json'], env=env))
|
||||
assert set(model['services']) == {'initialize', 'homegate', 'ssh-export', 'ui'}
|
||||
for name, service in model['services'].items():
|
||||
assert 'build' not in service, name
|
||||
assert service['image'] == env['HOMEGATE_IMAGE']
|
||||
assert all(v['type'] == 'volume' for v in service.get('volumes', [])), name
|
||||
if name != 'initialize':
|
||||
assert service['user'] == '1000:1000'
|
||||
assert service['depends_on']['initialize']['condition'] == 'service_completed_successfully'
|
||||
for port in service.get('ports', []):
|
||||
assert port['host_ip'] == env['HOMEGATE_LAN_IP']
|
||||
assert model['services']['initialize']['network_mode'] == 'none'
|
||||
assert not model['services']['initialize'].get('secrets')
|
||||
assert not model['services']['ssh-export'].get('secrets')
|
||||
assert [v['source'] for v in model['services']['ui']['secrets']] == ['ui_password']
|
||||
for name in ('ui', 'ssh-export'):
|
||||
assert all(v['target'] != '/data' for v in model['services'][name]['volumes'])
|
||||
assert set(model['secrets']) == {'ui_password', 'npm_password', 'pihole_password'}
|
||||
assert all('environment' in s and 'file' not in s for s in model['secrets'].values())
|
||||
seed = h.validate_config(yaml.safe_load(model['configs']['initial-config']['content']))
|
||||
assert seed['services'] == [] and seed['ssh_hosts'] == []
|
||||
subprocess.run(['docker', 'compose', '--env-file', '.env.example', '-f', 'compose.yaml',
|
||||
'config', '--quiet'], check=True, env=env)
|
||||
# The one-file deployment cannot accidentally fall back to all host interfaces.
|
||||
del env['HOMEGATE_LAN_IP']
|
||||
missing = subprocess.run(['docker', 'compose', '--env-file', os.devnull,
|
||||
'-f', 'compose.registry.yaml', 'config', '--quiet'],
|
||||
env=env, capture_output=True)
|
||||
assert missing.returncode != 0
|
||||
print('Build and registry Compose models validated; isolation and first-run defaults verified.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user