@@ -137,6 +137,7 @@ MULTIARCH_QEMU_ENVIRON = y
137
137
endif
138
138
endif
139
139
SLAVE_IMAGE = $(SLAVE_BASE_IMAGE)-$(USER_LC)
140
+ DOCKER_ROOT = $(PWD)/fsroot.docker.$(BLDENV)
140
141
141
142
# Support FIPS feature, armhf not supported yet
142
143
ifeq ($(PLATFORM_ARCH),armhf)
@@ -181,6 +182,7 @@ endif
181
182
DOCKER_LOCKFILE_SAVE := $(DOCKER_LOCKDIR)/docker_save.lock
182
183
$(shell mkdir -m 0777 -p $(DOCKER_LOCKDIR))
183
184
$(shell [ -f $(DOCKER_LOCKFILE_SAVE) ] || (touch $(DOCKER_LOCKFILE_SAVE) && chmod 0777 $(DOCKER_LOCKFILE_SAVE)))
185
+ $(shell sudo rm -rf $(DOCKER_ROOT) && mkdir -p $(DOCKER_ROOT))
184
186
185
187
ifeq ($(DOCKER_BUILDER_MOUNT),)
186
188
override DOCKER_BUILDER_MOUNT := "$(PWD):/sonic"
@@ -200,6 +202,11 @@ DOCKER_RUN := docker run --rm=true --privileged --init \
200
202
-i$(shell { if [ -t 0 ]; then echo t; fi }) \
201
203
$(SONIC_BUILDER_EXTRA_CMDLINE)
202
204
205
+ # Mount the $(DOCKER_ROOT) to /var/lib/docker in the slave container, the overlay fs is not supported as dockerd root folder.
206
+ ifneq ($(filter $(SONIC_SLAVE_DOCKER_DRIVER),overlay overlay2),)
207
+ DOCKER_RUN += -v $(DOCKER_ROOT):/var/lib/docker
208
+ endif
209
+
203
210
ifneq ($(DOCKER_BUILDER_USER_MOUNT),)
204
211
DOCKER_RUN += $(foreach mount,$(subst $(comma), ,$(DOCKER_BUILDER_USER_MOUNT)), $(addprefix -v , $(mount)))
205
212
endif
@@ -294,12 +301,18 @@ endif
294
301
295
302
endif
296
303
304
+ SPLIT_LOG = | tee
305
+
306
+ DOCKER_BASE_LOG = $(SLAVE_DIR)/$(SLAVE_BASE_IMAGE)_$(SLAVE_BASE_TAG).log
307
+ DOCKER_LOG = $(SLAVE_DIR)/$(SLAVE_IMAGE)_$(SLAVE_TAG).log
308
+
309
+
297
310
DOCKER_BASE_BUILD = docker build --no-cache \
298
311
-t $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) \
299
312
--build-arg http_proxy=$(http_proxy) \
300
313
--build-arg https_proxy=$(https_proxy) \
301
314
--build-arg no_proxy=$(no_proxy) \
302
- $(SLAVE_DIR)
315
+ $(SLAVE_DIR) $(SPLIT_LOG) $(DOCKER_BASE_LOG)
303
316
304
317
DOCKER_BASE_PULL = docker pull \
305
318
$(REGISTRY_SERVER):$(REGISTRY_PORT)/$(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG)
@@ -312,7 +325,7 @@ DOCKER_BUILD = docker build --no-cache \
312
325
--build-arg slave_base_tag_ref=$(SLAVE_BASE_TAG) \
313
326
-t $(SLAVE_IMAGE):$(SLAVE_TAG) \
314
327
-f $(SLAVE_DIR)/Dockerfile.user \
315
- $(SLAVE_DIR)
328
+ $(SLAVE_DIR) $(SPLIT_LOG) $(DOCKER_LOG)
316
329
317
330
SONIC_BUILD_INSTRUCTION := make \
318
331
-f slave.mk \
@@ -370,6 +383,7 @@ SONIC_BUILD_INSTRUCTION := make \
370
383
ENABLE_ASAN=$(ENABLE_ASAN) \
371
384
ENABLE_FIPS_FEATURE=$(ENABLE_FIPS_FEATURE) \
372
385
ENABLE_FIPS=$(ENABLE_FIPS) \
386
+ SONIC_SLAVE_DOCKER_DRIVER=$(SONIC_SLAVE_DOCKER_DRIVER) \
373
387
$(SONIC_OVERRIDE_BUILD_VARS)
374
388
375
389
.PHONY: sonic-slave-build sonic-slave-bash init reset
@@ -457,7 +471,7 @@ reset :
457
471
@read ans && (
458
472
if [ $$ans == y ]; then
459
473
echo "Resetting local repository. Please wait...";
460
- $(DOCKER_RUN) $(SLAVE_IMAGE):$(SLAVE_TAG) sudo rm -rf fsroot;
474
+ sudo rm -rf fsroot* ;
461
475
if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then
462
476
echo "Stopping march $(CONFIGURED_ARCH) docker"
463
477
sudo kill -9 `sudo cat /var/run/march/docker.pid` || true
0 commit comments