Use repo.build.vm as local build host

This commit is contained in:
Disassembler 2019-12-09 21:41:04 +01:00
parent 0351abcb92
commit 9532bc7405
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
8 changed files with 63 additions and 61 deletions

@ -1 +1 @@
Subproject commit ca10263696d9488ee384430b2e2a0bc55e877b77 Subproject commit ad1bfc8860b84148794f26c437a42b932087495f

View File

@ -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/*

View File

@ -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;

View File

@ -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

View File

@ -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,15 +20,16 @@ def pack_app(path):
app = App() app = App()
app.pack(path) app.pack(path)
if args.remove_image: def main(args):
if args.remove_image:
image = Image() image = Image()
image.name = args.buildarg image.name = args.buildarg
image.remove() image.remove()
elif args.remove_app: elif args.remove_app:
app = App() app = App()
app.name = args.buildarg app.name = args.buildarg
app.remove() app.remove()
else: else:
buildpath = os.path.realpath(args.buildarg) buildpath = os.path.realpath(args.buildarg)
# If the buildpath is a file, determine type from filename # If the buildpath is a file, determine type from filename
if os.path.isfile(buildpath): if os.path.isfile(buildpath):
@ -75,3 +63,17 @@ else:
pack_app(meta) pack_app(meta)
if not valid_dir: if not valid_dir:
print('Directory {} doesn\'t contain anything to build, skipping'.format(buildpath)) print('Directory {} doesn\'t contain anything to build, skipping'.format(buildpath))
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')
args = parser.parse_args()
if hasattr(args, 'buildarg'):
main(args)
else:
parser.print_usage()

View File

@ -20,7 +20,7 @@ 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
``` ```

View File

@ -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

View File

@ -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