-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
255 lines (240 loc) · 7.88 KB
/
docker-compose.yml
File metadata and controls
255 lines (240 loc) · 7.88 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# EasyLFS - Easy Linux From Scratch
# Docker Compose pipeline for building LFS 12.4 (SysVinit)
#
# Usage: Run services sequentially with:
# docker-compose run --rm <service-name>
#
# DO NOT use 'docker-compose up' - services must run in sequence!
services:
# ============================================================================
# Service 1: Download Sources (Chapter 3)
# Downloads all LFS source packages and patches
# ============================================================================
download-sources:
build:
context: ./services
dockerfile: download-sources/Dockerfile
container_name: easylfs-download-sources
volumes:
- lfs-sources:/sources
- lfs-logs:/logs
environment:
- LFS_VERSION=12.4
- LFS_MIRROR=https://www.linuxfromscratch.org
- SERVICE_NAME=download-sources
restart: "no"
# ============================================================================
# Service 2: Build Toolchain (Chapters 5-6)
# Compiles the temporary cross-compilation toolchain
# Duration: 2-4 hours
# ============================================================================
build-toolchain:
build:
context: ./services
dockerfile: build-toolchain/Dockerfile
container_name: easylfs-build-toolchain
cap_add:
- SYS_CHROOT
volumes:
- lfs-sources:/sources:ro
- lfs-tools:/tools
- lfs-rootfs:/lfs
- lfs-logs:/logs
environment:
- LFS=/lfs
- LFS_TGT=x86_64-lfs-linux-gnu
- MAKEFLAGS=-j4
- LC_ALL=POSIX
- SERVICE_NAME=build-toolchain
restart: "no"
depends_on:
download-sources:
condition: service_completed_successfully
# ============================================================================
# Service 3: Build Base System (Chapters 7-8)
# Enters chroot and builds the final LFS system
# Duration: 3-6 hours
# ============================================================================
build-basesystem:
build:
context: ./services
dockerfile: build-basesystem/Dockerfile
container_name: easylfs-build-basesystem
cap_add:
- SYS_CHROOT
- SYS_ADMIN # Required for mount operations
security_opt:
- apparmor:unconfined
volumes:
- lfs-sources:/sources:ro
- lfs-tools:/tools:ro
- lfs-rootfs:/lfs
- lfs-logs:/logs
environment:
- LFS=/lfs
- MAKEFLAGS=-j4
- LC_ALL=POSIX
- SERVICE_NAME=build-basesystem
restart: "no"
depends_on:
build-toolchain:
condition: service_completed_successfully
# ============================================================================
# Service 4: Configure System (Chapter 9)
# Creates system configuration files
# Duration: 10-20 minutes
# ============================================================================
configure-system:
build:
context: ./services
dockerfile: configure-system/Dockerfile
container_name: easylfs-configure-system
cap_add:
- SYS_CHROOT
- SYS_ADMIN # Required for mount operations
volumes:
- lfs-rootfs:/lfs
- lfs-logs:/logs
environment:
- LFS=/lfs
- HOSTNAME=lfs-system
- TIMEZONE=Europe/Rome
- SERVICE_NAME=configure-system
restart: "no"
depends_on:
build-basesystem:
condition: service_completed_successfully
# ============================================================================
# Service 5: Build Kernel (Chapter 10)
# Compiles the Linux kernel
# Duration: 20-60 minutes
# ============================================================================
build-kernel:
build:
context: ./services
dockerfile: build-kernel/Dockerfile
container_name: easylfs-build-kernel
volumes:
- lfs-sources:/sources:ro
- lfs-rootfs:/lfs
- lfs-logs:/logs
environment:
- LFS=/lfs
- MAKEFLAGS=-j4
- KERNEL_VERSION=6.12.6
- SERVICE_NAME=build-kernel
restart: "no"
depends_on:
configure-system:
condition: service_completed_successfully
# ============================================================================
# Service 6: Package Image (Chapter 11)
# Creates bootable disk image or ISO
# Duration: 15-30 minutes
# ============================================================================
package-image:
build:
context: ./services
dockerfile: package-image/Dockerfile
container_name: easylfs-package-image
privileged: true # Required for loop device access
volumes:
- lfs-rootfs:/lfs:ro
- lfs-dist:/dist
- lfs-logs:/logs
- /dev:/dev # Mount host /dev for loop device access
environment:
- LFS=/lfs
- IMAGE_NAME=lfs-12.4-sysv
- IMAGE_SIZE=5120 # Size in MB (5GB for final system - actual usage ~4.0GB)
- SERVICE_NAME=package-image
restart: "no"
depends_on:
build-kernel:
condition: service_completed_successfully
# ============================================================================
# Service 7: Test Suite
# Automated testing and validation
# ============================================================================
test:
build: ./tests
container_name: easylfs-test
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- lfs-sources:/volumes/lfs-sources:ro
- lfs-tools:/volumes/lfs-tools:ro
- lfs-rootfs:/volumes/lfs-rootfs:ro
- lfs-dist:/volumes/lfs-dist:ro
- .:/workspace:ro
working_dir: /tests
environment:
- COMPOSE_PROJECT_NAME=easylfs
restart: "no"
# ============================================================================
# Service 8: Web Terminal (ttyd)
# Browser-based terminal access to LFS system
# ============================================================================
lfs-web-terminal:
build:
context: ./services
dockerfile: lfs-web-terminal/Dockerfile
container_name: easylfs-web-terminal
ports:
- "${WEB_TERMINAL_PORT:-7681}:7681"
volumes:
- lfs-dist:/lfs-dist
environment:
- IMAGE_NAME=lfs-12.4-sysv
- WEB_TERMINAL_PORT=${WEB_TERMINAL_PORT:-7681}
restart: "no"
# ============================================================================
# Service 9: Web Screen (noVNC)
# Browser-based graphical console access to LFS system
# ============================================================================
lfs-web-screen:
build:
context: ./services
dockerfile: lfs-web-screen/Dockerfile
container_name: easylfs-web-screen
ports:
- "${WEB_SCREEN_PORT:-6080}:6080"
volumes:
- lfs-dist:/lfs-dist
environment:
- IMAGE_NAME=lfs-12.4-sysv
- WEB_SCREEN_PORT=${WEB_SCREEN_PORT:-6080}
- VNC_PORT=5900
restart: "no"
# ==============================================================================
# Named Volumes
# These persist build state across ephemeral containers
# Using external volumes to prevent Docker Compose from auto-prefixing with project name
# ==============================================================================
volumes:
# Source tarballs (populated by download-sources)
lfs-sources:
external: true
name: easylfs_lfs-sources
# Temporary toolchain (populated by build-toolchain)
lfs-tools:
external: true
name: easylfs_lfs-tools
# LFS root filesystem - the main artifact
lfs-rootfs:
external: true
name: easylfs_lfs-rootfs
# Final distribution artifacts (ISO/disk images)
lfs-dist:
external: true
name: easylfs_lfs-dist
# Build logs (one per service + master log)
lfs-logs:
external: true
name: easylfs_lfs-logs
# ==============================================================================
# Networks
# Default bridge network is sufficient for this sequential pipeline
# ==============================================================================
networks:
default:
driver: bridge