Skip to content

Commit

Permalink
[build]: add build option to use native docker instead of dind for build
Browse files Browse the repository at this point in the history
using native docker is faster than dind dockerd with vfs storage driver

sonic-net#2016

Azure/draft#181

Signed-off-by: Wataru Ishida <[email protected]>
  • Loading branch information
Wataru Ishida committed Oct 30, 2018
1 parent 6a37365 commit 5196161
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ DOCKER_RUN := docker run --rm=true --privileged \
-e "https_proxy=$(https_proxy)" \
-i$(if $(TERM),t,)

include rules/config

ifeq ($(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD), y)
DOCKER_RUN += -v /var/run/docker.sock:/var/run/docker.sock
endif

DOCKER_BASE_BUILD = docker build --no-cache \
-t $(SLAVE_BASE_IMAGE) \
--build-arg http_proxy=$(http_proxy) \
Expand Down
4 changes: 4 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ SONIC_CONFIG_BUILD_JOBS = 1
# Corresponding -j argument will be passed to make/dpkg commands that build separate packages
SONIC_CONFIG_MAKE_JOBS = $(shell nproc)

# SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD - use native dockerd for build.
# If set to y SONiC build container will use native dockerd instead of dind for faster build
# SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD = y

# SONIC_CONFIG_ENABLE_COLORS - enable colored output in build system.
# Comment next line to disable:
# SONIC_CONFIG_ENABLE_COLORS = y
Expand Down
2 changes: 1 addition & 1 deletion slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ $(SONIC_INSTALL_WHEELS) : $(PYTHON_WHEELS_PATH)/%-install : .platform $$(addsuff
docker-start :
@sudo sed -i '/http_proxy/d' /etc/default/docker
@sudo bash -c "echo \"export http_proxy=$$http_proxy\" >> /etc/default/docker"
@sudo service docker status &> /dev/null || ( sudo service docker start &> /dev/null && sleep 1 )
@test $(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) != "y" && sudo service docker status &> /dev/null || ( sudo service docker start &> /dev/null && sleep 1 )

# targets for building simple docker images that do not depend on any debian packages
$(addprefix $(TARGET_PATH)/, $(SONIC_SIMPLE_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform docker-start $$(addsuffix -load,$$(addprefix $(TARGET_PATH)/,$$($$*.gz_LOAD_DOCKERS)))
Expand Down

0 comments on commit 5196161

Please sign in to comment.