-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
133 lines (107 loc) · 3.21 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
FROM fedora:31
# Image info
LABEL description="Automated LFS build"
LABEL version="9.1-systemd"
LABEL maintainer="[email protected]"
# Distribution codename
ENV DISTRIB_CODENAME="my-linux"
# 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 4"
# Network configuration
ENV NET_DEV_NAME "eth0"
ENV NET_DEV_MAC "12:34:56:78:ab:cd"
# Language configuration
ENV LANG="en_US.UTF-8"
# Defines how toolchain is fetched
# 0 - use LFS wget file
# 1 - use binaries from toolchain folder
ENV FETCH_TOOLCHAIN_MODE=1
# 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=4
# Loop device
ENV LOOP=/dev/loop0
# 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 dnf upgrade -y && dnf install -y \
make \
automake \
bison \
byacc \
bzip2 \
diffutils \
elfutils-libelf-devel \
findutils \
gcc \
gcc-c++ \
gmp-devel \
kernel-devel \
libmpc-devel \
mpfr-devel \
patch \
python3 \
texinfo \
wget \
which \
xz \
&& dnf autoremove -y \
&& rm -rf /etc/yum.repos.d/*
# 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 usermod -a -G root lfs
# 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 NET_DEV_NAME NET_DEV_MAC LANG DISTRIB_CODENAME"' >> /etc/sudoers
# Login as lfs user
USER lfs
COPY [ "config/.bash_profile", "config/.bashrc", "/home/lfs/" ]
RUN source ~/.bash_profile
# Go!
ENTRYPOINT [ "/tools/run-all.sh" ]
# ENTRYPOINT [ "/bin/bash" ]