aynic.os 2 years ago
parent 10de1d466e
commit 24b4f6988b
  1. 4
      make/def.docker.mk
  2. 4
      make/def.mk
  3. 8
      make/env.mk

@ -55,13 +55,13 @@ else
SHELL := /bin/bash
define docker-run
$(ECHO) docker run $(DOCKER_RUN_OPTIONS) $(patsubst %,--env-file %,$(ENV_FILE)) $(foreach var,$(ENV_VARS),$(if $($(var)),-e $(var)='$($(var))')) $(shell printenv |awk -F '=' 'NR == FNR { if($$1 !~ /^(\#|$$)/) { A[$$1]; next } } ($$1 in A) {print "-e "$$0}' .env.dist - 2>/dev/null) $(DOCKER_RUN_VOLUME) $(DOCKER_RUN_WORKDIR) $(or $(1),$(DOCKER_IMAGE):$(DOCKER_IMAGE_TAG)) $(2)
$(ECHO) docker run $(DOCKER_RUN_OPTIONS) $(patsubst %,--env-file %,$(ENV_FILE)) $(env.docker.args) $(env.docker.dist) $(DOCKER_RUN_VOLUME) $(DOCKER_RUN_WORKDIR) $(or $(1),$(DOCKER_IMAGE):$(DOCKER_IMAGE_TAG)) $(2)
endef
define exec
$(call run,sh -c '$(or $(1),$(SHELL))')
endef
define run
IFS=$$'\n'; $(ECHO) env $(ENV_ARGS) $$(cat $(ENV_FILE) 2>/dev/null |awk -F "=" '$$1 ~! /^\(#|$$\)/') $(1)
IFS=$$'\n'; env $(env_reset) $(env.args) $(env.dist) $(env.file) $(1)
endef
endif

@ -55,9 +55,9 @@ VERBOSE ?= true
VERSION ?= $(shell git describe --tags $(BRANCH) 2>/dev/null || git rev-parse $(BRANCH) 2>/dev/null)
ifeq ($(DOCKER), true)
ENV_ARGS = $(foreach var,$(ENV_VARS),$(if $($(var)),-e $(var)='$($(var))')) $(shell printenv |awk -F '=' 'NR == FNR { if($$1 !~ /^(\#|$$)/) { A[$$1]; next } } ($$1 in A) {print "-e "$$0}' .env.dist - 2>/dev/null)
ENV_ARGS = $(env.docker.args) $(env.docker.dist)
else
ENV_ARGS = $(foreach var,$(ENV_VARS),$(if $($(var)),$(var)='$($(var))')) $(shell printenv |awk -F '=' 'NR == FNR { if($$1 !~ /^(\#|$$)/) { A[$$1]; next } } ($$1 in A)' .env.dist - 2>/dev/null)
ENV_ARGS = $(env.args) $(env.dist)
endif
ifneq ($(DEBUG), true)

@ -7,14 +7,18 @@
# include .env file
-include .env
env = IFS=$$'\n'; env $(env_reset) $(env_vars) "$(env.dist)" "$(env.file)" sh -c '$(1)'
env = $(env.args) "$(env.dist)" "$(env.file)"
env.docker = $(env.docker.args) "$(env.docker.dist)" $(env.docker.file)
env.args = $(foreach var,$(ENV_VARS),$(if $($(var)),$(var)='$($(var))'))
env.dist = $(shell printenv |awk -F '=' 'NR == FNR { if($$1 !~ /^(\#|$$)/) { A[$$1]; next } } ($$1 in A)' .env.dist - 2>/dev/null)
env.file = $(shell cat $(ENV_FILE) 2>/dev/null |sed '/^[ \t]*$$/d;/^[ \t]*\#/d;')
env.docker.args = $(foreach var,$(ENV_VARS),$(if $($(var)),-e $(var)='$($(var))'))
env.docker.dist = $(shell printenv |awk -F '=' 'NR == FNR { if($$1 !~ /^(\#|$$)/) { A[$$1]; next } } ($$1 in A) {print "-e "$$0}' .env.dist - 2>/dev/null)
env.docker.file = $(patsubst %,--env-file %,$(ENV_FILE))
ifneq (,$(filter true,$(ENV_RESET)))
env_reset := -i
endif
env_vars = $(foreach var,$(ENV_VARS),$(if $($(var)),$(var)='$($(var))'))
SHELL:=/bin/bash

Loading…
Cancel
Save