aynic.os 1 year ago
parent 24b4f6988b
commit e4deca629e
  1. 4
      Makefile
  2. 9
      make/def.docker.mk
  3. 11
      make/env.mk

@ -13,3 +13,7 @@ app-build: build-rm myos-base
app-deploy: deploy-ping
app-install: base node up
app-tests:
echo ENV: $(env)
echo DOCKER_ENV: $(DOCKER_ENV)

@ -1,6 +1,7 @@
COMPOSE_VERSION ?= 1.24.1
COMPOSE_PROJECT_NAME_MYOS ?= $(USER)_$(ENV)_myos
COMPOSE_PROJECT_NAME_NODE ?= node
DOCKER_ENV ?= $(env.docker)
DOCKER_EXEC_OPTIONS ?=
DOCKER_IMAGE ?= $(DOCKER_IMAGE_CLI)
DOCKER_IMAGE_CLI ?= $(DOCKER_REPOSITORY_MYOS)/cli
@ -44,24 +45,24 @@ define exec
endef
else
define exec
$(ECHO) docker exec $(ENV_ARGS) $(DOCKER_EXEC_OPTIONS) $(DOCKER_RUN_WORKDIR) $(DOCKER_NAME) sh -c '$(or $(1),$(SHELL))'
$(ECHO) docker exec $(DOCKER_EXEC_OPTIONS) $(DOCKER_ENV) $(DOCKER_RUN_WORKDIR) $(DOCKER_NAME) sh -c '$(or $(1),$(SHELL))'
endef
endif
define run
$(ECHO) docker run $(DOCKER_RUN_OPTIONS) $(patsubst %,--env-file %,$(ENV_FILE)) $(ENV_ARGS) $(DOCKER_RUN_VOLUME) $(DOCKER_RUN_WORKDIR) $(1)
$(ECHO) docker run $(DOCKER_RUN_OPTIONS) $(DOCKER_ENV) $(DOCKER_RUN_VOLUME) $(DOCKER_RUN_WORKDIR) $(1)
endef
else
SHELL := /bin/bash
define docker-run
$(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)
$(ECHO) docker run $(DOCKER_RUN_OPTIONS) $(DOCKER_ENV) $(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'; env $(env_reset) $(env.args) $(env.dist) $(env.file) $(1)
IFS=$$'\n'; env $(env_reset) $(env) $(1)
endef
endif

@ -7,8 +7,12 @@
# include .env file
-include .env
env = $(env.args) "$(env.dist)" "$(env.file)"
env.docker = $(env.docker.args) "$(env.docker.dist)" $(env.docker.file)
ifneq (,$(filter true,$(ENV_RESET)))
env_reset := -i
endif
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)
@ -16,9 +20,6 @@ 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
SHELL:=/bin/bash

Loading…
Cancel
Save