-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathDockerfile
executable file
·111 lines (89 loc) · 3.01 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
FROM debian:10-slim
# image info
LABEL description="Automated LFS build"
LABEL version="8.2"
LABEL maintainer="ilya.builuk@gmail.com"
# LFS mount point
ENV LFS=/mnt/lfs
# Other LFS parameters
ENV LC_ALL=POSIX
ENV LFS_TGT=x86_64-lfs-linux-gnu
ENV PATH=/tools/bin:/bin:/usr/bin:/sbin:/usr/sbin
ENV MAKEFLAGS="-j 1"
# Defines how toolchain is fetched
# 0 use LFS wget file
# 1 use binaries from toolchain folder
# 2 use github release artifacts
ENV FETCH_TOOLCHAIN_MODE=2
# set 1 to run tests; running tests takes much more time
ENV LFS_TEST=0
# set 1 to install documentation; slightly increases final size
ENV LFS_DOCS=0
# degree of parallelism for compilation
ENV JOB_COUNT=1
# inital ram disk size in KB
# must be in sync with CONFIG_BLK_DEV_RAM_SIZE
ENV IMAGE_SIZE=900000
# location of initrd tree
ENV INITRD_TREE=/mnt/lfs
# output image
ENV IMAGE=isolinux/ramdisk.img
# set bash as default shell
WORKDIR /bin
RUN rm sh && ln -s bash sh
# install required packages
RUN apt-get update && apt-get install -y \
build-essential \
bison \
file \
gawk \
texinfo \
wget \
sudo \
genisoimage \
libelf-dev \
bc \
libssl-dev \
&& apt-get -q -y autoremove \
&& rm -rf /var/lib/apt/lists/*
# create sources directory as writable and sticky
RUN mkdir -pv $LFS/sources \
&& chmod -v a+wt $LFS/sources
WORKDIR $LFS/sources
# create tools directory and symlink
RUN mkdir -pv $LFS/tools \
&& ln -sv $LFS/tools /
# copy local binaries if present
COPY ["toolchain/", "$LFS/sources/"]
# copy scripts
COPY [ "scripts/run-all.sh", \
"scripts/library-check.sh", \
"scripts/version-check.sh", \
"scripts/prepare/", \
"scripts/build/", \
"scripts/image/", \
"$LFS/tools/" ]
# copy configuration
COPY [ "config/kernel.config", "$LFS/tools/" ]
# check environment
RUN chmod +x $LFS/tools/*.sh \
&& sync \
&& $LFS/tools/version-check.sh \
&& $LFS/tools/library-check.sh
# create lfs user with 'lfs' password
RUN groupadd lfs \
&& useradd -s /bin/bash -g lfs -m -k /dev/null lfs \
&& echo "lfs:lfs" | chpasswd
RUN adduser lfs sudo
# give lfs user ownership of directories
RUN chown -v lfs $LFS/tools \
&& chown -v lfs $LFS/sources
# avoid sudo password
RUN echo "lfs ALL = NOPASSWD : ALL" >> /etc/sudoers
RUN echo 'Defaults env_keep += "LFS LC_ALL LFS_TGT PATH MAKEFLAGS FETCH_TOOLCHAIN_MODE LFS_TEST LFS_DOCS JOB_COUNT LOOP IMAGE_SIZE INITRD_TREE IMAGE"' >> /etc/sudoers
# login as lfs user
USER lfs
COPY [ "config/.bash_profile", "config/.bashrc", "/home/lfs/" ]
RUN source ~/.bash_profile
# let's the party begin
ENTRYPOINT [ "/tools/run-all.sh" ]