speed up things
add DOCKER_MACHINE and DOCKER_SYSTEM to .env to avoid waisting time every call
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
DOCKER_MACHINE=${DOCKER_MACHINE}
|
||||
DOCKER_SYSTEM=${DOCKER_SYSTEM}
|
||||
+3
-1
@@ -192,7 +192,9 @@ ssh@%:
|
||||
## it updates COMPOSE_FILE with all .yml files of the current stack
|
||||
.PHONY: stack
|
||||
stack:
|
||||
$(foreach stackz,$(STACK),$(call docker-stack,$(stackz)))
|
||||
$(if $(filter-out . myos,$(MYOS)), \
|
||||
$(call compose-file,. docker), \
|
||||
$(foreach stackz,$(STACK),$(call docker-stack,$(stackz))))
|
||||
$(call compose-file,$(MYOS_STACK),$(MYOS_STACK_FILE))
|
||||
|
||||
# target stack-%: Call docker-compose-% target on STACK
|
||||
|
||||
@@ -27,7 +27,7 @@ DOCKER_BUILD_TARGET ?= $(if $(filter $(ENV),$(DOCKER_BUILD_TARGETS))
|
||||
DOCKER_BUILD_TARGET_DEFAULT ?= master
|
||||
DOCKER_BUILD_TARGETS ?= $(ENV_DEPLOY)
|
||||
DOCKER_BUILD_VARS ?= APP BRANCH COMPOSE_VERSION DOCKER_GID DOCKER_MACHINE DOCKER_REPOSITORY DOCKER_SYSTEM GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME SSH_REMOTE_HOSTS USER VERSION
|
||||
DOCKER_COMPOSE := $(or $(shell docker-compose --version 2>/dev/null |awk '$$4 != "v'"$(COMPOSE_VERSION)"'" {exit 1} END {if (NR == 0) exit 1}' && printf 'docker-compose\n'),$(shell docker compose >/dev/null 2>&1 && printf 'docker compose\n'))
|
||||
DOCKER_COMPOSE ?= $(or $(shell docker-compose --version 2>/dev/null |awk '$$4 != "v'"$(COMPOSE_VERSION)"'" {exit 1} END {if (NR == 0) exit 1}' && printf 'docker-compose\n'),$(shell docker compose >/dev/null 2>&1 && printf 'docker compose\n'))
|
||||
DOCKER_COMPOSE_ARGS ?= --ansi=auto
|
||||
DOCKER_COMPOSE_DOWN_OPTIONS ?=
|
||||
DOCKER_COMPOSE_FILE ?= docker-compose
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ DOCKER_ENV_ARGS ?= $(docker_env_args)
|
||||
DOCKER_EXEC_OPTIONS ?=
|
||||
DOCKER_GID ?= $(call gid,docker)
|
||||
DOCKER_IMAGE ?= $(USER_DOCKER_IMAGE)
|
||||
DOCKER_MACHINE := $(shell docker run --rm alpine uname -m 2>/dev/null)
|
||||
DOCKER_MACHINE ?= $(shell docker run --rm alpine uname -m 2>/dev/null)
|
||||
DOCKER_NAME ?= $(USER_DOCKER_NAME)
|
||||
DOCKER_NETWORK ?= $(if $(USER_STACK),$(USER),$(DOCKER_NETWORK_PRIVATE))
|
||||
DOCKER_NETWORK_PRIVATE ?= $(USER)-$(ENV)
|
||||
@@ -16,7 +16,7 @@ DOCKER_RUN_NETWORK += --network $(DOCKER_NETWORK)
|
||||
DOCKER_RUN_OPTIONS += --rm
|
||||
DOCKER_RUN_VOLUME ?= $(patsubst %,-v %,$(DOCKER_VOLUME))
|
||||
DOCKER_RUN_WORKDIR ?= $(if $(DOCKER_WORKDIR),-w $(DOCKER_WORKDIR))
|
||||
DOCKER_SYSTEM := $(shell docker run --rm alpine uname -s 2>/dev/null)
|
||||
DOCKER_SYSTEM ?= $(shell docker run --rm alpine uname -s 2>/dev/null)
|
||||
DOCKER_VOLUME ?= /var/run/docker.sock:/var/run/docker.sock
|
||||
DOCKER_WORKDIR ?= $(PWD)
|
||||
ENV_VARS += DOCKER_MACHINE DOCKER_NETWORK DOCKER_NETWORK_PRIVATE DOCKER_NETWORK_PUBLIC DOCKER_SYSTEM HOST_COMPOSE_PROJECT_NAME HOST_COMPOSE_SERVICE_NAME HOST_DOCKER_REPOSITORY HOST_DOCKER_VOLUME HOST_GID HOST_UID USER_COMPOSE_PROJECT_NAME USER_COMPOSE_SERVICE_NAME USER_DOCKER_IMAGE USER_DOCKER_NAME USER_DOCKER_REPOSITORY USER_DOCKER_VOLUME
|
||||
|
||||
+7
-2
@@ -136,6 +136,11 @@ MACHINE ?= $(shell uname -m 2>/dev/null)
|
||||
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
SED_SUFFIX := ''
|
||||
STAT_FORMAT_ARG := -f
|
||||
STAT_FORMAT_FILE := '%a %N'
|
||||
else
|
||||
STAT_FORMAT_ARG := -c
|
||||
STAT_FORMAT_FILE := '%Y %n'
|
||||
endif
|
||||
|
||||
# include .env files
|
||||
@@ -226,10 +231,10 @@ force = $$(while true; do \
|
||||
gid = $(shell awk -F':' '$$1 == "$(1)" {print $$3}' /etc/group 2>/dev/null)
|
||||
|
||||
# macro newer: Return the newest file
|
||||
newer = $(shell stat -c '%Y %n' $(1) $(2) $(if $(DEBUG),,2>/dev/null) |sort -n |tail -n1 |awk '{print $$2}')
|
||||
newer = $(shell stat $(STAT_FORMAT_ARG) $(STAT_FORMAT_FILE) $(1) $(2) $(if $(DEBUG),,2>/dev/null) |sort -n |tail -n1 |awk '{print $$2}')
|
||||
|
||||
# older newer: Return the oldest file
|
||||
older = $(shell stat -c '%Y %n' $(1) $(2) $(if $(DEBUG),,2>/dev/null) |sort -n |head -n1 |awk '{print $$2}')
|
||||
older = $(shell stat $(STAT_FORMAT_ARG) $(STAT_FORMAT_FILE) $(1) $(2) $(if $(DEBUG),,2>/dev/null) |sort -n |head -n1 |awk '{print $$2}')
|
||||
|
||||
# macro pop: Return last word of string 1 according to separator 2
|
||||
pop = $(patsubst %$(or $(2),/)$(lastword $(subst $(or $(2),/), ,$(1))),%,$(1))
|
||||
|
||||
+5
-3
@@ -74,10 +74,11 @@ endef
|
||||
# create a new (empty if ENV_RESET is true) environment with env.args
|
||||
# read environment variables and keep only those existing in .env.dist
|
||||
# add .env overrides variables definition
|
||||
# add .env.dist variables definition
|
||||
# add .env.dist variables definition when variable value is not the variable name itself
|
||||
# remove empty lines or comments
|
||||
# remove duplicate variables
|
||||
# replace variables in stdin with their value from the new environment
|
||||
# eval and replace commands in stdin with their result
|
||||
# remove residual empty lines or comments
|
||||
# sort alphabetically
|
||||
# add variables definition to the .env file
|
||||
@@ -95,10 +96,11 @@ define .env_update
|
||||
env $(env_reset) $(env.args) \
|
||||
$$(env |awk -F '=' 'NR == FNR { if($$1 !~ /^(#|$$)/) { A[$$1]; next } } ($$1 in A)' $(env_dist) - \
|
||||
|cat - $(env_over) \
|
||||
|cat - $(env_dist) \
|
||||
|cat - $(env_dist) |awk -F '=' '{ if(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH-3);if(var!=$$1) print} else print}' \
|
||||
|sed -e /^$$/d -e /^#/d \
|
||||
|awk -F '=' '!seen[$$1]++') \
|
||||
awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH-3);gsub("[$$]{"var"}",ENVIRON[var])} print}') \
|
||||
awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH-3);if("$${"var"}"!=ENVIRON[var]){gsub("[$$]{"var"}",ENVIRON[var])}else{gsub("[$$]{"var"}","")}}; \
|
||||
while(match($$0,"[$$]\\([^\\)]*\\)")) {cmd=substr($$0,RSTART+2,RLENGTH-3);cmd|getline var;gsub("[$$]\\([^\\)]*\\)",var);close(cmd)} print}') \
|
||||
|sed -e /^$$/d -e /^#/d \
|
||||
|sort \
|
||||
>> $(env_file) $(if $(VERBOSE)$(DEBUG),,2> /dev/null) ||:;
|
||||
|
||||
Reference in New Issue
Block a user