Use repo.build.vm as local build host
This commit is contained in:
parent
0351abcb92
commit
9532bc7405
@ -1 +1 @@
|
|||||||
Subproject commit ca10263696d9488ee384430b2e2a0bc55e877b77
|
Subproject commit ad1bfc8860b84148794f26c437a42b932087495f
|
@ -44,16 +44,13 @@ cat <<EOF >/etc/hosts
|
|||||||
127.0.0.1 localhost
|
127.0.0.1 localhost
|
||||||
::1 localhost
|
::1 localhost
|
||||||
172.17.0.1 host
|
172.17.0.1 host
|
||||||
172.17.0.1 repo.spotter.cz
|
172.17.0.1 repo.build.vm
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Reset vmmgr config
|
# Reset vmmgr config
|
||||||
export ADMINPWD=$(python3 -c "import json; f = open('/etc/vmmgr/config.json'); j = json.load(f); print(j['host']['adminpwd'])")
|
export ADMINPWD=$(python3 -c "import json; f = open('/etc/vmmgr/config.json'); j = json.load(f); print(j['host']['adminpwd'])")
|
||||||
envsubst </etc/vmmgr/config.default.json >/etc/vmmgr/config.json
|
envsubst </etc/vmmgr/config.default.json >/etc/vmmgr/config.json
|
||||||
|
|
||||||
# Reset lxcmgr config
|
|
||||||
echo '{"url":"https://repo.spotter.cz/lxc","user":"","pwd":""}' >/etc/lxcmgr/repo.json
|
|
||||||
|
|
||||||
# Clean locally installed LXC packages
|
# Clean locally installed LXC packages
|
||||||
rm -rf /var/lib/lxcmgr/storage/*
|
rm -rf /var/lib/lxcmgr/storage/*
|
||||||
rm -rf /var/lib/lxcmgr/cache/apps/*
|
rm -rf /var/lib/lxcmgr/cache/apps/*
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
server {
|
server {
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
server_name repo.spotter.cz;
|
server_name repo.build.vm;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /srv/build;
|
root /srv/build;
|
||||||
|
@ -28,9 +28,12 @@ mkdir -p /srv/build/lxc/apps /srv/build/lxc/images
|
|||||||
|
|
||||||
# Prepare local APK repository
|
# Prepare local APK repository
|
||||||
cp etc/nginx/conf.d/apkrepo.conf /etc/nginx/conf.d/apkrepo.conf
|
cp etc/nginx/conf.d/apkrepo.conf /etc/nginx/conf.d/apkrepo.conf
|
||||||
echo "172.17.0.1 repo.spotter.cz" >>/etc/hosts
|
echo "172.17.0.1 repo.build.vm" >>/etc/hosts
|
||||||
service nginx reload
|
service nginx reload
|
||||||
|
|
||||||
|
# Change LXCMgr repository
|
||||||
|
echo '{"url":"http://repo.build.vm/lxc","user":"","pwd":""}' >/etc/lxcmgr/repo.json
|
||||||
|
|
||||||
# Supply abuild key
|
# Supply abuild key
|
||||||
# echo '/srv/build/repokey.rsa' | abuild-keygen
|
# echo '/srv/build/repokey.rsa' | abuild-keygen
|
||||||
|
|
||||||
|
@ -8,19 +8,6 @@ from lxcbuild.app import App
|
|||||||
from lxcbuild.image import Image
|
from lxcbuild.image import Image
|
||||||
from lxcbuild.imagebuilder import BuildType
|
from lxcbuild.imagebuilder import BuildType
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='VM application builder and packager')
|
|
||||||
group = parser.add_mutually_exclusive_group()
|
|
||||||
group.add_argument('-f', '--force', action='store_true', help='Force rebuild already built package')
|
|
||||||
group.add_argument('-s', '--scratch', action='store_true', help='Build container for testing purposes, i.e. without cleanup on failure and packaging')
|
|
||||||
group.add_argument('-r', '--remove-image', action='store_true', help='Delete image (including scratch) from build repository')
|
|
||||||
group.add_argument('-e', '--remove-app', action='store_true', help='Delete application from build repository')
|
|
||||||
parser.add_argument('buildarg', help='Either specific "lxcfile" or "meta" file or a directory containing at least one of them')
|
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
parser.print_usage()
|
|
||||||
sys.exit(1)
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
def build_and_pack_image(path, args):
|
def build_and_pack_image(path, args):
|
||||||
image = Image()
|
image = Image()
|
||||||
if args.scratch:
|
if args.scratch:
|
||||||
@ -33,45 +20,60 @@ def pack_app(path):
|
|||||||
app = App()
|
app = App()
|
||||||
app.pack(path)
|
app.pack(path)
|
||||||
|
|
||||||
if args.remove_image:
|
def main(args):
|
||||||
image = Image()
|
if args.remove_image:
|
||||||
image.name = args.buildarg
|
image = Image()
|
||||||
image.remove()
|
image.name = args.buildarg
|
||||||
elif args.remove_app:
|
image.remove()
|
||||||
app = App()
|
elif args.remove_app:
|
||||||
app.name = args.buildarg
|
app = App()
|
||||||
app.remove()
|
app.name = args.buildarg
|
||||||
else:
|
app.remove()
|
||||||
buildpath = os.path.realpath(args.buildarg)
|
|
||||||
# If the buildpath is a file, determine type from filename
|
|
||||||
if os.path.isfile(buildpath):
|
|
||||||
basename = os.path.basename(buildpath)
|
|
||||||
if basename == 'lxcfile' or basename.endswith('.lxcfile'):
|
|
||||||
build_and_pack_image(buildpath, args)
|
|
||||||
# Compose files needs to be ignored when performing scratch builds
|
|
||||||
elif not args.scratch and basename == 'meta':
|
|
||||||
pack_app(buildpath)
|
|
||||||
else:
|
|
||||||
print('Unknown file {} given, expected "lxcfile"{}'.format(buildpath, '' if args.scratch else ' or "meta"'))
|
|
||||||
sys.exit(1)
|
|
||||||
# If the buildpath is a directory, build as much as possible, unless scratch build was requested, in which case don't build anything
|
|
||||||
else:
|
else:
|
||||||
if args.scratch:
|
buildpath = os.path.realpath(args.buildarg)
|
||||||
lxcfile = os.path.join(buildpath, 'lxcfile')
|
# If the buildpath is a file, determine type from filename
|
||||||
if os.path.exists(lxcfile):
|
if os.path.isfile(buildpath):
|
||||||
build_and_pack_image(lxcfile, args)
|
basename = os.path.basename(buildpath)
|
||||||
|
if basename == 'lxcfile' or basename.endswith('.lxcfile'):
|
||||||
|
build_and_pack_image(buildpath, args)
|
||||||
|
# Compose files needs to be ignored when performing scratch builds
|
||||||
|
elif not args.scratch and basename == 'meta':
|
||||||
|
pack_app(buildpath)
|
||||||
else:
|
else:
|
||||||
print('Please specify an lxcfile for scratch build')
|
print('Unknown file {} given, expected "lxcfile"{}'.format(buildpath, '' if args.scratch else ' or "meta"'))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
# If the buildpath is a directory, build as much as possible, unless scratch build was requested, in which case don't build anything
|
||||||
else:
|
else:
|
||||||
valid_dir = False
|
if args.scratch:
|
||||||
for entry in os.scandir(buildpath):
|
lxcfile = os.path.join(buildpath, 'lxcfile')
|
||||||
if entry.is_file() and (entry.name == 'lxcfile' or entry.name.endswith('.lxcfile')):
|
if os.path.exists(lxcfile):
|
||||||
|
build_and_pack_image(lxcfile, args)
|
||||||
|
else:
|
||||||
|
print('Please specify an lxcfile for scratch build')
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
valid_dir = False
|
||||||
|
for entry in os.scandir(buildpath):
|
||||||
|
if entry.is_file() and (entry.name == 'lxcfile' or entry.name.endswith('.lxcfile')):
|
||||||
|
valid_dir = True
|
||||||
|
build_and_pack_image(entry.path, args)
|
||||||
|
meta = os.path.join(buildpath, 'meta')
|
||||||
|
if os.path.exists(meta):
|
||||||
valid_dir = True
|
valid_dir = True
|
||||||
build_and_pack_image(entry.path, args)
|
pack_app(meta)
|
||||||
meta = os.path.join(buildpath, 'meta')
|
if not valid_dir:
|
||||||
if os.path.exists(meta):
|
print('Directory {} doesn\'t contain anything to build, skipping'.format(buildpath))
|
||||||
valid_dir = True
|
|
||||||
pack_app(meta)
|
parser = argparse.ArgumentParser(description='VM application builder and packager')
|
||||||
if not valid_dir:
|
group = parser.add_mutually_exclusive_group()
|
||||||
print('Directory {} doesn\'t contain anything to build, skipping'.format(buildpath))
|
group.add_argument('-f', '--force', action='store_true', help='Force rebuild already built package')
|
||||||
|
group.add_argument('-s', '--scratch', action='store_true', help='Build container for testing purposes, i.e. without cleanup on failure and packaging')
|
||||||
|
group.add_argument('-r', '--remove-image', action='store_true', help='Delete image (including scratch) from build repository')
|
||||||
|
group.add_argument('-e', '--remove-app', action='store_true', help='Delete application from build repository')
|
||||||
|
parser.add_argument('buildarg', help='Either specific "lxcfile" or "meta" file or a directory containing at least one of them')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
if hasattr(args, 'buildarg'):
|
||||||
|
main(args)
|
||||||
|
else:
|
||||||
|
parser.print_usage()
|
||||||
|
@ -19,8 +19,8 @@ Download **Alpine Virtual 3.9.0 x86_64** from <https://alpinelinux.org/downloads
|
|||||||
setup-interfaces
|
setup-interfaces
|
||||||
ifup eth0
|
ifup eth0
|
||||||
|
|
||||||
# Download and launch the setup script
|
# Download and launch the setup script
|
||||||
wget repo.spotter.cz/vm.sh
|
wget https://repo.spotter.cz/vm.sh
|
||||||
sh vm.sh
|
sh vm.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
|
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
|
||||||
http://dl-cdn.alpinelinux.org/alpine/v3.9/community
|
http://dl-cdn.alpinelinux.org/alpine/v3.9/community
|
||||||
@vm http://repo.spotter.cz/alpine/v3.9/apk
|
@vm http://repo.build.vm/alpine/v3.9/apk
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
|
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
|
||||||
http://dl-cdn.alpinelinux.org/alpine/v3.9/community
|
http://dl-cdn.alpinelinux.org/alpine/v3.9/community
|
||||||
@vm http://repo.spotter.cz/alpine/v3.9/apk
|
@vm https://repo.spotter.cz/alpine/v3.9/apk
|
||||||
|
Loading…
Reference in New Issue
Block a user