diff --git a/bin/build b/bin/build index ba9b3ef..5724ce7 100644 --- a/bin/build +++ b/bin/build @@ -1,19 +1 @@ -FILE=$DOCKER_HOME/images/$1.mk -echo $FILE -if [[ ! -e $FILE ]]; then - DELETE=true - FILE="$(mktemp)" - echo 123 - cat <<- EOF > $FILE - include \$(DOCKER_HOME)/build/Makefile - - NAME = $1 - VERSION = latest - - build: $1 -EOF -fi -make -f $FILE build -if [ ! -z ${DELETE+x} ]; then - rm $FILE -fi \ No newline at end of file +$DOCKER_HOME/bin/make $1 build \ No newline at end of file diff --git a/bin/make b/bin/make index 508bcc6..13a1072 100644 --- a/bin/make +++ b/bin/make @@ -1 +1,15 @@ -make -f $DOCKER_HOME/images/$1.mk $2 +FILE=$DOCKER_HOME/images/$1.mk +if [[ ! -e $FILE ]]; then + DELETE=true + FILE="$(mktemp)" + cat <<- EOF > $FILE + include \$(DOCKER_HOME)/build/Makefile + NAME = $1 + VERSION = latest + build: $1 +EOF +fi +make -f $FILE $2 +if [ ! -z ${DELETE+x} ]; then + rm $FILE +fi diff --git a/build/Makefile b/build/Makefile index 4067e6d..8b4708e 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,7 +1,6 @@ RANDOM = $(shell bash -c 'echo $$RANDOM') HOME = $(DOCKER_HOME) BASE = $(HOME)/build -FILE = $(BASE)/Dockerfile TMP = /build/tmp FROM = ubuntu:trusty INTERFACE = eth0 @@ -19,13 +18,13 @@ define execute endef define boot - @$(eval TARGET := '/opt/init.d/$(1)_$(2)') + @$(eval TARGET = '/opt/init.d/$(1)_$(2)') $(call add,boot/$(2).sh,$(TARGET)) @echo 'RUN chmod +x $(TARGET)' >> ${FILE} endef define runit - @$(eval TARGET := '/etc/service/$(1)/run') + @$(eval TARGET = '/etc/service/$(1)/run') $(call add,runit/$(1),$(TARGET)) @echo 'RUN mkdir -p /etc/service/$(1)' >> ${FILE} @echo 'RUN chmod +x $(TARGET)' >> ${FILE} @@ -41,9 +40,11 @@ build: prepare base $(call script,cleanup) @echo 'RUN chmod +x /opt/init.d/*' >> ${FILE} @echo 'CMD ["/opt/init"]' >> ${FILE} - @docker build -t $(NAME):$(VERSION) $(ARGS) ${BASE} + @docker build -t $(NAME):$(VERSION) $(ARGS) -f $(FILE) $(BASE) + @rm ${FILE} prepare: + @$(eval FILE = $(shell mktemp -p $(BASE))) @echo FROM $(FROM) > ${FILE} @echo ENV MODE $(MODE) >> ${FILE} $(call add,config,/build/config)