-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
54 lines (41 loc) · 1.18 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM ubuntu:eoan
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
build-essential \
bc \
curl \
cpio \
golang \
qemu-system \
git \
&& apt-get clean
WORKDIR /kernel-build
RUN curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.7.tar.xz \
&& tar xf linux-4.7.tar.xz
RUN cd linux-4.7 \
&& make x86_64_defconfig kvmconfig \
&& make -j$(nproc)
WORKDIR /initfs/
RUN qemu-img create -f raw disk.img 500M \
&& echo -e "n\np\n1\n\n\nw" | fdisk disk.img \
&& echo "y" | mkfs.ext4 disk.img \
&& mkdir fs
# Setup go
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
RUN cd /initfs/fs \
&& mkdir -vm 0755 dev \
&& mkdir -vm 0755 run \
&& mkdir -v proc sys
WORKDIR /src/
COPY . busygox
RUN cd /src/busygox \
&& CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-s -w' -o /initfs/fs/init ./cmd/init \
&& cd /initfs/fs && find . -print0 | cpio --null -ov --format=newc > /initfs/initramfs.cpio \
&& ldd init || true \
&& du -h /initfs/initramfs.cpio
RUN go version
ENTRYPOINT ["/src/busygox/entrypoint.sh"]