IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
瀏覽代碼

Started implementing focker compose

tags/0.92
父節點
當前提交
b4a8c24c1f
共有 2 個文件被更改,包括 59 次插入0 次删除
  1. +56
    -0
      compose.py
  2. +3
    -0
      focker-compose.yml

+ 56
- 0
compose.py 查看文件

@@ -0,0 +1,56 @@
import os
import yaml
from .zfs import AmbiguousValueError, \
zfs_find, \
zfs_tag
from .misc import random_sha256_hexdigest, \
find_prefix
import subprocess
def build_volumes(spec):
for tag in spec.keys():
try:
name, _ = zfs_find(tag, focker_type='volume')
continue
except AmbiguousValueError:
raise
except ValueError:
pass
sha256 = random_sha256_hexdigest()
name = find_prefix(poolname + '/focker/volumes/', sha256)
subprocess.check_output(['zfs', 'create', name])
zfs_untag([ tag ], focker_type='volume')
zfs_tag(name, [ tag ])
def build_images(spec, path):
# print('build_images(): NotImplementedError')
for (tag, focker_dir) in spec.items():
res = subprocess.run(['focker', 'image', 'build',
os.path.join(path, focker_dir), '-t', tag])
if res.returncode != 0:
raise RuntimeError('Image build failed: ' + str(res.returncode))
def build_jails(spec):
print('build_jails(): NotImplementedError')
def command_compose_build(args):
if not os.path.exists(args.filename):
raise ValueError('File not found: ' + args.filename)
path, _ = os.path.split(args.filename)
with open(args.filename, 'r') as f:
spec = yaml.safe_load(f)
if 'volumes' in spec:
build_volumes(spec['volumes'])
if 'images' in spec:
build_images(spec['images'], path)
if 'jails' in spec:
build_jails(spec['jails'])
def command_compose_run(args):
raise NotImplementedError

+ 3
- 0
focker-compose.yml 查看文件

@@ -4,6 +4,9 @@
# focker compose wordpress.yml restore
#
images:
wordpress-5: .
jails:
wordpress:
image: wordpress-5


Loading…
取消
儲存