Compare commits

...
3 Commits
3 changed files with 14 additions and 5 deletions
+1 -1
View File
@@ -156,7 +156,7 @@ define docker-stack-update
$(eval stack_update := $(patsubst %.yml,%,$(notdir $(1))))
$(eval stack_name := $(firstword $(subst :, ,$(stack_update))))
$(eval stack_version := $(or $(2),$(if $(findstring :,$(stack_update)),$(lastword $(subst :, ,$(stack_update))),latest)))
$(eval stack_path := $(patsubst %/,%,$(or $(3),$(foreach stack_dir,$(STACK_DIR),$(if $(findstring /,$(1)),$(if $(wildcard $(stack_dir)/$(1) $(stack_dir)/$(1).yml),$(stack_dir)/$(if $(findstring .yml,$(1)),$(dir $(1)),$(if $(wildcard $(stack_dir)/$(1).yml),$(dir $(1)),$(1))),$(if $(wildcard $(stack_dir)/$(stackz)/$(1) $(stack_dir)/$(stackz)/$(1).yml),$(stack_dir)/$(stackz)/$(if $(findstring .yml,$(1)),$(dir $(1)),$(if $(wildcard $(stack_dir)/$(stackz)/$(1).yml),$(dir $(1)),$(1))),$(dir $(1)))))),$(foreach stack_dir,$(STACK_DIR),$(firstword $(wildcard $(stack_dir)/$(stackz)/$(stack_name) $(stack_dir)/$(stackz) $(stack_dir)/$(stack_name)))))))
$(eval stack_path := $(patsubst %/,%,$(or $(3),$(realpath $(foreach stack_dir,$(STACK_DIR),$(if $(findstring /,$(1)),$(if $(wildcard $(stack_dir)/$(1) $(stack_dir)/$(1).yml),$(stack_dir)/$(if $(findstring .yml,$(1)),$(dir $(1)),$(if $(wildcard $(stack_dir)/$(1).yml),$(dir $(1)),$(1))),$(if $(wildcard $(stack_dir)/$(stackz)/$(1) $(stack_dir)/$(stackz)/$(1).yml),$(stack_dir)/$(stackz)/$(if $(findstring .yml,$(1)),$(dir $(1)),$(if $(wildcard $(stack_dir)/$(stackz)/$(1).yml),$(dir $(1)),$(1))),$(dir $(1)))))),$(foreach stack_dir,$(STACK_DIR),$(firstword $(wildcard $(stack_dir)/$(stackz)/$(stack_name) $(stack_dir)/$(stackz) $(stack_dir)/$(stack_name))))))))
$(call debug,stack_path)
$(call compose-file,$(stack_path),docker-compose $(stack_name),$(COMPOSE_FILE_SUFFIX) $(stack_version))
$(if $(wildcard $(stack_path)/.env.dist),$(call .env,,$(stack_path)/.env.dist,$(wildcard $(CONFIG)/$(ENV)/$(APP)/.env $(stack_path)/.env.$(ENV) .env)))
+4
View File
@@ -14,6 +14,10 @@ DOCKER_NETWORK ?= $(if $(USER_STACK),$(USER),$(DOCKER_NETWORK_P
DOCKER_NETWORK_DEFAULT ?= _$(COMPOSE_PROJECT_NAME)
DOCKER_NETWORK_PRIVATE ?= $(USER)-$(ENV)
DOCKER_NETWORK_PUBLIC ?= $(HOSTNAME)
# The myos networks.yml is appended to COMPOSE_FILE after the per-stack
# env-vars scan, so these infra vars must always reach compose or the
# external network names fall back to their placeholders.
ENV_VARS += DOCKER_NETWORK_DEFAULT DOCKER_NETWORK_PRIVATE DOCKER_NETWORK_PUBLIC
# DOCKER_RUN: if empty, run system command, else run it in a docker
DOCKER_RUN ?= $(if $(filter-out false False FALSE,$(DOCKER)),$(DOCKER))
DOCKER_RUN_ENTRYPOINT ?= $(patsubst %,--entrypoint=%,$(DOCKER_ENTRYPOINT))
+9 -4
View File
@@ -5,11 +5,16 @@ set -eu
# define MYOS path
MYOS="$(dirname "$(readlink "$0" || echo "$0")")"
# load system config
[ -r /etc/default/myos ] && . /etc/default/myos
# load system config: /etc/conf.d/myos (openrc convention) first, then the
# debian-style /etc/default/myos as fallback
MYOS_CONF=/etc/conf.d/myos
[ -r "$MYOS_CONF" ] || MYOS_CONF=/etc/default/myos
[ -r "$MYOS_CONF" ] && . "$MYOS_CONF"
# check myos requirements
[ -f "${MYOS:-.}/Makefile" ] || { echo 'Unable to find myos Makefile' >&2; exit 1; }
# call myos Makefile
IFS=$'\n'; exec env $(cat /etc/default/myos 2>/dev/null) MYOS=. WORKDIR="${PWD}" make -esC "${MYOS:-.}" "$@"
# call myos Makefile: a WORKDIR from the config or environment wins over PWD,
# so a machine can pin its deployment dir and run myos from anywhere
IFS=$'\n'; exec env $(cat "$MYOS_CONF" 2>/dev/null) MYOS=. WORKDIR="${WORKDIR:-${PWD}}" make -esC "${MYOS:-.}" "$@"