Modify setup for more flexible building process
This commit is contained in:
@@ -1,14 +1,54 @@
|
|||||||
include $(wildcard /opt/docker/build/make/*.mk)
|
HOME = $(DOCKER_HOME)
|
||||||
BASE = /opt/docker/build
|
BASE = $(HOME)/build
|
||||||
|
DIR = $(HOME)/images/$(NAME)
|
||||||
|
FILE = $(DIR)/Dockerfile
|
||||||
|
FROM = ubuntu:trusty
|
||||||
|
PORT = 8001
|
||||||
|
MODE = minimal
|
||||||
|
ARGS = --no-cache
|
||||||
|
|
||||||
|
include $(wildcard $(HOME)/build/make/*.mk)
|
||||||
|
|
||||||
|
define download
|
||||||
|
@echo 'RUN wget -q $(1) $$HOST_ADDR:$$HOST_PORT/$(2) $(3)' >> ${FILE}
|
||||||
|
endef
|
||||||
|
|
||||||
|
define execute
|
||||||
|
$(call download,-O -,$(1),| bash)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define script
|
||||||
|
$(call execute,scripts/$(1).sh)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define boot
|
||||||
|
$(call download,-O /opt/init.d/$(1)_$(2),boot/$(2).sh)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define runit
|
||||||
|
@echo 'RUN mkdir -p /etc/service/$(1)' >> ${FILE}
|
||||||
|
$(call download,-O /etc/service/$(1)/run,runit/$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
all: build bin service clean
|
all: build bin service clean
|
||||||
|
|
||||||
build:
|
build: prepare
|
||||||
cp $(BASE)/Dockerfile .
|
$(call script,cleanup)
|
||||||
docker build -t $(NAME):$(VERSION) --rm .
|
@echo 'CMD ["/opt/init"]' >> ${FILE}
|
||||||
|
@$(shell cd ${BASE} && python -m SimpleHTTPServer $(PORT) > /dev/null &)
|
||||||
|
@docker build -t $(NAME):$(VERSION) --rm=true $(ARGS) ${DIR}
|
||||||
|
@kill -9 $(lsof -i tcp:8001 -t)
|
||||||
|
|
||||||
directory:
|
prepare:
|
||||||
@mkdir -p build/boot build/runit build/scripts
|
@echo FROM $(FROM) > ${FILE}
|
||||||
|
@echo ENV MODE $(MODE) >> ${FILE}
|
||||||
|
@$(eval HOST_ADDR := $(shell ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $$1}'))
|
||||||
|
@echo ENV HOST_ADDR $(HOST_ADDR) >> ${FILE}
|
||||||
|
@echo ENV HOST_PORT $(PORT) >> ${FILE}
|
||||||
|
@echo 'RUN apt-get install -y wget' >> ${FILE}
|
||||||
|
$(call download,-P /build,config,)
|
||||||
|
$(call download,-P /build,init)
|
||||||
|
$(call script,prepare)
|
||||||
|
|
||||||
service:
|
service:
|
||||||
@if test "${DEPENDS}" != ""; then \
|
@if test "${DEPENDS}" != ""; then \
|
||||||
@@ -23,6 +63,7 @@ service:
|
|||||||
@mv init.conf /etc/init/docker-$(NAME).conf
|
@mv init.conf /etc/init/docker-$(NAME).conf
|
||||||
|
|
||||||
bin:
|
bin:
|
||||||
|
@rm -r bin
|
||||||
@mkdir -p bin
|
@mkdir -p bin
|
||||||
@ln -sf $(BASE)/bin/run bin
|
@ln -sf $(BASE)/bin/run bin
|
||||||
@ln -sf $(BASE)/bin/ssh bin
|
@ln -sf $(BASE)/bin/ssh bin
|
||||||
@@ -31,7 +72,7 @@ bin:
|
|||||||
@sed -i "1iARGS=\"$(SSH)\"" bin/ssh
|
@sed -i "1iARGS=\"$(SSH)\"" bin/ssh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -f Dockerfile
|
@rm -f ${FILE}
|
||||||
@rm -rf build
|
@rm -rf build
|
||||||
@rm -rf id_rsa
|
@rm -rf id_rsa
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
base: directory cron syslog sshd hosts
|
base: cron syslog sshd hosts
|
||||||
ln -f $(BASE)/config build
|
# $(call script,boot)
|
||||||
ln -f $(BASE)/init build
|
# $(call script,init)
|
||||||
ln -f $(BASE)/scripts/*_prepare.sh build/scripts
|
# $(call script,runit)
|
||||||
ln -f $(BASE)/scripts/*_boot.sh build/scripts
|
# $(call script,logrotate)
|
||||||
ln -f $(BASE)/scripts/*_init.sh build/scripts
|
# $(call script,utilities)
|
||||||
ln -f $(BASE)/scripts/*_runit.sh build/scripts
|
|
||||||
ln -f $(BASE)/scripts/*_logrotate.sh build/scripts
|
|
||||||
ln -f $(BASE)/scripts/*_utilities.sh build/scripts
|
|
||||||
ln -f $(BASE)/scripts/*_cleanup.sh build/scripts
|
|
||||||
2
build/make/compile.mk
Normal file
2
build/make/compile.mk
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
compile:
|
||||||
|
ln -f $(BASE)/scripts/*_$@.sh build/scripts
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
cron:
|
cron:
|
||||||
ln -f $(BASE)/scripts/*_$@.sh build/scripts
|
$(call script,$@)
|
||||||
ln -f $(BASE)/runit/$@ build/runit
|
$(call runit,$@)
|
||||||
3
build/make/gmrender.mk
Normal file
3
build/make/gmrender.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
gmrender: compile
|
||||||
|
cp $(BASE)/scripts/*_$@.sh build/scripts
|
||||||
|
cp $(BASE)/runit/$@ build/runit
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
hosts:
|
hosts:
|
||||||
ln -f $(BASE)/scripts/*_$@.sh build/scripts
|
$(call script,$@)
|
||||||
ln -f $(BASE)/boot/*_$@.sh build/boot
|
$(call boot,01,$@)
|
||||||
2
build/make/logrotate.mk
Normal file
2
build/make/logrotate.mk
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
logrotate:
|
||||||
|
ln -f $(BASE)/scripts/*_$@.sh build/scripts
|
||||||
3
build/make/minidlna.mk
Normal file
3
build/make/minidlna.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
minidlna: compile
|
||||||
|
ln -f $(BASE)/scripts/*_$@.sh build/scripts
|
||||||
|
ln -f $(BASE)/runit/$@ build/runit
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
sshd:
|
sshd:
|
||||||
ln -f $(BASE)/scripts/*_$@.sh build/scripts
|
$(call script,$@)
|
||||||
ln -f $(BASE)/runit/$@ build/runit
|
$(call runit,$@)
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
syslog:
|
syslog:
|
||||||
ln -f $(BASE)/scripts/*_$@.sh build/scripts
|
$(call script,$@)
|
||||||
ln -f $(BASE)/runit/$@ build/runit
|
$(call runit,$@)
|
||||||
3
build/make/upnpproxy.mk
Normal file
3
build/make/upnpproxy.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
upnpproxy: compile
|
||||||
|
cp $(BASE)/scripts/*_$@.sh build/scripts
|
||||||
|
cp $(BASE)/runit/$@ build/runit
|
||||||
Reference in New Issue
Block a user