Skip to content

Commit 7cfeddf

Browse files
committed
initial docker build support
1 parent 490bc62 commit 7cfeddf

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM local/stage0 as stage0
2+
3+
FROM debian as fetch
4+
RUN apt update && apt install -y curl gcc
5+
ADD . live-bootstrap
6+
WORKDIR live-bootstrap
7+
RUN ./download-distfiles.sh
8+
RUN mv target/ /rootfs/
9+
10+
FROM scratch as build
11+
COPY --from=fetch /rootfs .
12+
ENV PATH=/bin
13+
RUN ["/bootstrap-seeds/POSIX/x86/kaem-optional-seed"]

rootfs.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create_configuration_file(args):
2929
config_path = os.path.join('steps', 'bootstrap.cfg')
3030
with open(config_path, "w", encoding="utf_8") as config:
3131
config.write(f"FORCE_TIMESTAMPS={args.force_timestamps}\n")
32-
config.write(f"CHROOT={args.chroot or args.bwrap}\n")
32+
config.write(f"CHROOT={args.chroot or args.bwrap or args.docker}\n")
3333
config.write(f"UPDATE_CHECKSUMS={args.update_checksums}\n")
3434
config.write(f"JOBS={args.cores}\n")
3535
config.write(f"SWAP_SIZE={args.swap}\n")
@@ -62,6 +62,8 @@ def main():
6262
action="store_true")
6363
parser.add_argument("-bw", "--bwrap", help="Run inside a bwrap sandbox",
6464
action="store_true")
65+
parser.add_argument("-do", "--docker", help="Run inside a docker build",
66+
action="store_true")
6567
parser.add_argument("-t", "--target", help="Target directory",
6668
default="target")
6769
parser.add_argument("--tmpfs", help="Use a tmpfs on target",
@@ -121,15 +123,17 @@ def check_types():
121123
count += 1
122124
if args.bwrap:
123125
count += 1
126+
if args.docker:
127+
count += 1
124128
if args.bare_metal:
125129
count += 1
126130
return count
127131

128132
if check_types() > 1:
129-
raise ValueError("No more than one of qemu, chroot, bwrap, bare metal"
133+
raise ValueError("No more than one of qemu, chroot, bwrap, docker, bare metal"
130134
"may be used.")
131135
if check_types() == 0:
132-
raise ValueError("One of qemu, chroot, bwrap, or bare metal must be selected.")
136+
raise ValueError("One of qemu, chroot, bwrap, docker, or bare metal must be selected.")
133137

134138
# Arch validation
135139
if args.arch != "x86":
@@ -199,6 +203,16 @@ def bootstrap(args, generator, target, size):
199203
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', arch, 'kaem-optional-seed')
200204
run_as_root('env', '-i', 'PATH=/bin', chroot_binary, generator.target_dir, init)
201205

206+
elif args.docker:
207+
generator.prepare(target, using_kernel=False)
208+
arch = stage0_arch_map.get(args.arch, args.arch)
209+
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', arch, 'kaem-optional-seed')
210+
print(generator.target_dir, init)
211+
run('env', '-i', 'DOCKER_BUILDKIT=1', 'docker', 'build',
212+
'--progress=plain',
213+
'-t', 'local/live',
214+
'.')
215+
202216
elif args.bwrap:
203217
init = '/init'
204218
if not args.internal_ci or args.internal_ci == "pass1":

0 commit comments

Comments
 (0)