initial docker build support

This commit is contained in:
Lance R. Vick 2024-01-13 12:36:12 -08:00 committed by Kevin Nause
parent 63b24502c7
commit e327b20cc8
2 changed files with 30 additions and 3 deletions

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM local/stage0 as stage0
FROM debian as fetch
RUN apt update && apt install -y curl gcc
ADD . live-bootstrap
WORKDIR live-bootstrap
RUN ./download-distfiles.sh
RUN mv target/ /rootfs/
FROM scratch as build
COPY --from=fetch /rootfs .
ENV PATH=/bin
RUN ["/bootstrap-seeds/POSIX/x86/kaem-optional-seed"]

View file

@ -34,7 +34,7 @@ def create_configuration_file(args):
config.write(f"ARCH={args.arch}\n")
config.write(f"ARCH_DIR={stage0_arch_map.get(args.arch, args.arch)}\n")
config.write(f"FORCE_TIMESTAMPS={args.force_timestamps}\n")
config.write(f"CHROOT={args.chroot or args.bwrap}\n")
config.write(f"CHROOT={args.chroot or args.bwrap or args.docker}\n")
config.write(f"UPDATE_CHECKSUMS={args.update_checksums}\n")
config.write(f"JOBS={args.cores}\n")
config.write(f"SWAP_SIZE={args.swap}\n")
@ -75,6 +75,8 @@ def main():
action="store_true")
parser.add_argument("-bw", "--bwrap", help="Run inside a bwrap sandbox",
action="store_true")
parser.add_argument("-do", "--docker", help="Run inside a docker build",
action="store_true")
parser.add_argument("-t", "--target", help="Target directory",
default="target")
parser.add_argument("--tmpfs", help="Use a tmpfs on target",
@ -140,15 +142,17 @@ def main():
count += 1
if args.bwrap:
count += 1
if args.docker:
count += 1
if args.bare_metal:
count += 1
return count
if check_types() > 1:
raise ValueError("No more than one of qemu, chroot, bwrap, bare metal"
raise ValueError("No more than one of qemu, chroot, bwrap, docker, bare metal"
"may be used.")
if check_types() == 0:
raise ValueError("One of qemu, chroot, bwrap, or bare metal must be selected.")
raise ValueError("One of qemu, chroot, bwrap, docker, or bare metal must be selected.")
# Arch validation
if args.arch != "x86":
@ -250,6 +254,16 @@ print(shutil.which('chroot'))
run_as_root('env', '-i', 'PATH=/bin', chroot_binary, generator.target_dir, init,
cleanup=cleanup)
elif args.docker:
generator.prepare(target, using_kernel=False)
arch = stage0_arch_map.get(args.arch, args.arch)
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', arch, 'kaem-optional-seed')
print(generator.target_dir, init)
run('env', '-i', 'DOCKER_BUILDKIT=1', 'docker', 'build',
'--progress=plain',
'-t', 'local/live',
'.')
elif args.bwrap:
init = '/init'
if not args.internal_ci or args.internal_ci == "pass1":