update apps: bionicgpt
This commit is contained in:
parent
2699a04c84
commit
1a731109ea
|
@ -1,4 +1,4 @@
|
|||
APP_REPOSITORY_URL ?= https://github.com/purton-tech/bionicgpt
|
||||
APP_VERSION ?= v1.1.14
|
||||
ENV_VARS += BIONICGPT_ENVOY_SERVICE_7700_TAGS
|
||||
BIONICGPT_ENVOY_SERVICE_7700_TAGS ?= $(call tagprefix)
|
||||
BIONICGPT_REPOSITORY_URL ?= https://github.com/purton-tech/bionicgpt
|
||||
BIONICGPT_VERSION ?= v1.3.3
|
||||
ENV_VARS += BIONICGPT_ENVOY_SERVICE_7700_TAGS
|
||||
|
|
|
@ -23,7 +23,7 @@ services:
|
|||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
|
||||
embeddings-job:
|
||||
pipeline-job:
|
||||
environment:
|
||||
APP_DATABASE_URL: postgresql://${BIONICGPT_DB_APP_USER:-ft_application}:${BIONICGPT_DB_APP_PASSWORD:-testpassword}@db:5432/${BIONICGPT_DB_POSTGRES_DB:-finetuna}?sslmode=disable
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
APP_DOCKER_DIR ?= deploy/docker/clickhouse-setup
|
||||
APP_REPOSITORY_URL ?= https://github.com/SigNoz/signoz
|
||||
APP_VERSION ?= v0.34.3
|
||||
ENV_VARS += SIGNOZ_FRONTEND_SERVICE_3301_TAGS
|
||||
SIGNOZ_DOCKER_DIR ?= deploy/docker/clickhouse-setup
|
||||
SIGNOZ_FRONTEND_SERVICE_3301_TAGS ?= $(call urlprefix)
|
||||
SIGNOZ_REPOSITORY_URL ?= https://github.com/SigNoz/signoz
|
||||
SIGNOZ_VERSION ?= v0.34.3
|
||||
STACK += alerting/apprise
|
||||
|
|
|
@ -200,7 +200,7 @@ stack:
|
|||
## the last part of %
|
||||
## ex: stack-host-up will fire the docker-compose-up target in the host stack
|
||||
.PHONY: stack-%
|
||||
stack-%:
|
||||
stack-%: stack
|
||||
$(eval stack := $(subst -$(lastword $(subst -, ,$*)),,$*))
|
||||
$(eval command := $(lastword $(subst -, ,$*)))
|
||||
$(if $(findstring -,$*), \
|
||||
|
@ -240,7 +240,7 @@ upgrade: update app-upgrade release-upgrade ## Upgrade application
|
|||
|
||||
# target %: Always fired target
|
||||
## it fires the stack and %-rule-exists targets everytime
|
||||
%: FORCE stack %-rule-exists ;
|
||||
%: FORCE %-rule-exists ;
|
||||
|
||||
# target %-rule-exists: Print a warning message if % target does not exists
|
||||
%-rule-exists:
|
||||
|
|
|
@ -27,9 +27,10 @@ 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
|
||||
DOCKER_COMPOSE_LOGS_OPTIONS ?= --follow --tail=100
|
||||
DOCKER_COMPOSE_PROJECT_NAME ?= $(if $(HOST_STACK),$(HOST_COMPOSE_PROJECT_NAME),$(if $(USER_STACK),$(USER_COMPOSE_PROJECT_NAME)))
|
||||
DOCKER_COMPOSE_RUN_ENTRYPOINT ?= $(patsubst %,--entrypoint=%,$(DOCKER_COMPOSE_ENTRYPOINT))
|
||||
|
@ -64,11 +65,11 @@ DOCKER_COMPOSE_DOWN_OPTIONS := --rmi all -v
|
|||
DOCKER_COMPOSE_UP_OPTIONS := -d --build
|
||||
endif
|
||||
|
||||
# function compose-file: Search compose files to load
|
||||
# function compose-file: Search compose files to update variable COMPOSE_FILE
|
||||
define compose-file
|
||||
$(call INFO,compose-file,$(1)$(comma) $(2)$(comma) $(3)$(comma) $(4))
|
||||
$(eval path := $(or $(1),. ./docker))
|
||||
$(eval name := $(or $(2),docker-compose))
|
||||
$(eval path := $(or $(1),. $(APP_DOCKER_DIR)))
|
||||
$(eval name := $(or $(2),$(DOCKER_COMPOSE_FILE)))
|
||||
$(eval suffix := $(or $(3),$(COMPOSE_FILE_SUFFIX)))
|
||||
$(eval extension := $(or $(4),yml yaml))
|
||||
$(eval COMPOSE_FILE += $(wildcard $(foreach e,$(extension),$(foreach n,$(name),$(foreach p,$(path),$(p)/$(n).$(e) $(p)/$(n).$(ENV).$(e) $(foreach s,$(suffix),$(p)/$(n).$(s).$(e) $(p)/$(n).$(s).$(ENV).$(e)))))))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
APP_DIR ?= $(CURDIR)
|
||||
APP_DOCKER_DIR ?= $(DOCKER_DIR)
|
||||
APP_DOMAIN ?= $(patsubst %,$(APP_DOMAIN_PREFIX)%,$(DOMAIN))
|
||||
APP_DOMAIN_PREFIX ?= $(if $(HOST_STACK),,$(addsuffix .,$(filter-out $(ENV_DEPLOY),$(ENV)))$(USER).)
|
||||
APP_HOST ?= $(patsubst %,$(APP_HOST_PREFIX)%,$(APP_DOMAIN))$(if $(HOST_LB),$(space)$(APP_DOMAIN))
|
||||
|
@ -19,6 +20,7 @@ APP_UPSTREAM_REPOSITORY ?= $(or $(shell git config --get remote.upstream
|
|||
APP_URI ?= $(patsubst %,%/$(APP_PATH),$(APP_HOST))
|
||||
APP_URIS ?= $(APP_URI)
|
||||
APP_URL ?= $(patsubst %,$(APP_SCHEME)://%,$(APP_URI))
|
||||
APP_VERSION ?= $(VERSION)
|
||||
CONTEXT += APP APPS BRANCH DOMAIN VERSION RELEASE
|
||||
CONTEXT_DEBUG += APP_DIR APP_URL APP_REPOSITORY APP_UPSTREAM_REPOSITORY ENV_DEPLOY
|
||||
ENV_DEPLOY ?= $(patsubst origin/%,%,$(shell git rev-parse --symbolic --remotes=origin |sed '/origin\/HEAD/d' 2>/dev/null))
|
||||
|
|
|
@ -8,59 +8,59 @@ docker-build: docker-images-myos
|
|||
|
||||
# target docker-build-%: Call docker-build for each Dockerfile in docker/% folder
|
||||
.PHONY: docker-build-%
|
||||
docker-build-%:
|
||||
docker-build-%: stack
|
||||
$(if $(wildcard docker/$*/Dockerfile),$(call docker-build,docker/$*))
|
||||
$(if $(findstring :,$*),$(eval DOCKER_FILE := $(wildcard docker/$(subst :,/,$*)/Dockerfile)),$(eval DOCKER_FILE := $(wildcard docker/$*/*/Dockerfile)))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),$(call docker-build,$(dir $(dockerfile)),$(DOCKER_REPOSITORY)/$(word 2,$(subst /, ,$(dir $(dockerfile)))):$(lastword $(subst /, ,$(dir $(dockerfile)))),""))
|
||||
|
||||
# target docker-commit: Call docker-commit for each SERVICES
|
||||
.PHONY: docker-commit
|
||||
docker-commit:
|
||||
docker-commit: stack
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-commit,$(service)))
|
||||
|
||||
# target docker-commit-%: Call docker-commit with tag % for each SERVICES
|
||||
.PHONY: docker-commit-%
|
||||
docker-commit-%:
|
||||
docker-commit-%: stack
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-commit,$(service),,,$*))
|
||||
|
||||
# target docker-compose-build: Fire docker-images-myos, Call docker-compose build SERVICE
|
||||
.PHONY: docker-compose-build
|
||||
docker-compose-build: DOCKER_RUN_OPTIONS += -it
|
||||
docker-compose-build: docker-images-myos
|
||||
docker-compose-build: docker-images-myos stack
|
||||
$(call docker-compose,build $(DOCKER_BUILD_ARGS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-config: Call docker-compose config
|
||||
.PHONY: docker-compose-config
|
||||
docker-compose-config:
|
||||
docker-compose-config: stack
|
||||
$(call docker-compose,config)
|
||||
|
||||
# target docker-compose-connect: Call docker-compose exec SERVICE DOCKER_SHELL
|
||||
.PHONY: docker-compose-connect
|
||||
docker-compose-connect: SERVICE ?= $(DOCKER_SERVICE)
|
||||
docker-compose-connect: DOCKER_RUN_OPTIONS += -it
|
||||
docker-compose-connect:
|
||||
docker-compose-connect: stack
|
||||
$(call docker-compose,exec $(SERVICE) $(DOCKER_SHELL))
|
||||
|
||||
# target docker-compose-down: Call docker-compose rm SERVICE or docker-compose down
|
||||
.PHONY: docker-compose-down
|
||||
docker-compose-down: DOCKER_RUN_OPTIONS += -it
|
||||
docker-compose-down:
|
||||
docker-compose-down: stack
|
||||
$(if $(filter $(SERVICE),$(SERVICES)),$(call docker-compose,rm -fs $(SERVICE)),$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS) ||:))
|
||||
|
||||
# target docker-compose-exec: Call docker-compose-exec SERVICE ARGS
|
||||
.PHONY: docker-compose-exec
|
||||
docker-compose-exec: SERVICE ?= $(DOCKER_SERVICE)
|
||||
docker-compose-exec:
|
||||
docker-compose-exec: stack
|
||||
$(call docker-compose-exec-sh,$(SERVICE),$(ARGS))
|
||||
|
||||
# target docker-compose-logs: Call docker-compose logs SERVICE
|
||||
.PHONY: docker-compose-logs
|
||||
docker-compose-logs:
|
||||
docker-compose-logs: stack
|
||||
$(call docker-compose,logs $(DOCKER_COMPOSE_LOGS_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-ps: Call docker-compose ps
|
||||
.PHONY: docker-compose-ps
|
||||
docker-compose-ps:
|
||||
docker-compose-ps: stack
|
||||
$(call docker-compose,ps)
|
||||
|
||||
# target docker-compose-rebuild: Call docker-compose-build target with DOCKER_BUILD_NO_CACHE=true
|
||||
|
@ -74,42 +74,42 @@ docker-compose-recreate: docker-compose-rm docker-compose-up
|
|||
|
||||
# target docker-compose-restart: Call docker-compose restart SERVICE
|
||||
.PHONY: docker-compose-restart
|
||||
docker-compose-restart:
|
||||
docker-compose-restart: stack
|
||||
$(call docker-compose,restart $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-rm: Call docker-compose rm SERVICE
|
||||
.PHONY: docker-compose-rm
|
||||
docker-compose-rm: DOCKER_RUN_OPTIONS += -it
|
||||
docker-compose-rm:
|
||||
docker-compose-rm: stack
|
||||
$(call docker-compose,rm -fs $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-run: Call docker-compose run SERVICE ARGS
|
||||
.PHONY: docker-compose-run
|
||||
docker-compose-run: SERVICE ?= $(DOCKER_SERVICE)
|
||||
docker-compose-run: DOCKER_RUN_OPTIONS += -it
|
||||
docker-compose-run:
|
||||
docker-compose-run: stack
|
||||
$(call docker-compose,run $(DOCKER_COMPOSE_RUN_OPTIONS) $(SERVICE) $(ARGS))
|
||||
|
||||
# target docker-compose-scale: Call docker-compose up --scale SERVICE=NUM
|
||||
.PHONY: docker-compose-scale
|
||||
docker-compose-scale: SERVICE ?= $(DOCKER_SERVICE)
|
||||
docker-compose-scale:
|
||||
docker-compose-scale: stack
|
||||
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) --scale $(SERVICE)=$(NUM))
|
||||
|
||||
# target docker-compose-start: Call docker-compose start SERVICE
|
||||
.PHONY: docker-compose-start
|
||||
docker-compose-start:
|
||||
docker-compose-start: stack
|
||||
$(call docker-compose,start $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-stop: Call docker-compose stop SERVICE
|
||||
.PHONY: docker-compose-stop
|
||||
docker-compose-stop:
|
||||
docker-compose-stop: stack
|
||||
$(call docker-compose,stop $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-up: Fire docker-image-myos, Call docker-compose up SERVICE
|
||||
.PHONY: docker-compose-up
|
||||
docker-compose-up: DOCKER_RUN_OPTIONS += -it
|
||||
docker-compose-up: docker-images-myos bootstrap-stack
|
||||
docker-compose-up: docker-images-myos bootstrap-stack stack
|
||||
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-images-myos: Call myos-docker-build-% target for each DOCKER_IMAGES_MYOS
|
||||
|
@ -178,7 +178,7 @@ docker-plugin-install:
|
|||
|
||||
# target docker-push: Call docker-push for each SERVICES
|
||||
.PHONY: docker-push
|
||||
docker-push:
|
||||
docker-push: stack
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-push,$(service)))
|
||||
else
|
||||
|
@ -187,7 +187,7 @@ endif
|
|||
|
||||
# target docker-push-%: Call docker-push with tag % for each SERVICES
|
||||
.PHONY: docker-push-%
|
||||
docker-push-%:
|
||||
docker-push-%: stack
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-push,$(service),,$*))
|
||||
else
|
||||
|
@ -231,7 +231,7 @@ docker-run-%: docker-build-%
|
|||
|
||||
# target docker-tag: Call docker-tag for each SERVICES
|
||||
.PHONY: docker-tag
|
||||
docker-tag:
|
||||
docker-tag: stack
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-tag,$(service)))
|
||||
else
|
||||
|
@ -240,7 +240,7 @@ endif
|
|||
|
||||
# target docker-tag-%: Call docker-tag with target tag % for each SERVICES
|
||||
.PHONY: docker-tag-%
|
||||
docker-tag-%:
|
||||
docker-tag-%: stack
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-tag,$(service),,,,$*))
|
||||
else
|
||||
|
|
|
@ -10,13 +10,20 @@ $(APP): myos-user
|
|||
# target app-%: Call app-$(command) for APP in APP_DIR
|
||||
## it splits % on dashes and extracts app from the beginning and command from the last part of %
|
||||
## ex: app-foo-build will call app-build for app foo in ../foo
|
||||
## it includes apps/$(app)/*.mk file and hydrates APP_* variables
|
||||
## ex: APP_REPOSITORY_URL is set with value from variable $(APP)_REPOSITORY_URL
|
||||
.PHONY: app-%
|
||||
app-%:
|
||||
$(eval COMPOSE_FILE :=)
|
||||
$(eval STACK :=)
|
||||
$(eval app := $(subst -$(lastword $(subst -, ,$*)),,$*))
|
||||
$(eval command := $(lastword $(subst -, ,$*)))
|
||||
$(eval include $(wildcard apps/$(app).mk apps/$(app)/$(app).mk)) \
|
||||
$(eval include $(wildcard apps/def.mk apps/$(app).mk apps/$(app)/*.mk))
|
||||
$(foreach var,$(filter $(call UPPERCASE,$(app))_%,$(MAKE_FILE_VARS)), \
|
||||
$(if $(filter $(subst $(call UPPERCASE,$(app))_,APP_,$(var)),$(MAKE_FILE_VARS)), \
|
||||
$(eval $(subst $(call UPPERCASE,$(app))_,APP_,$(var)) := $($(var))) \
|
||||
) \
|
||||
)
|
||||
$(if $(wildcard $(RELATIVE)$(app)), \
|
||||
$(if $(filter app-$(command),$(.VARIABLES)), \
|
||||
$(call app-bootstrap,$(app)) \
|
||||
|
@ -29,7 +36,7 @@ app-%:
|
|||
) \
|
||||
) \
|
||||
, \
|
||||
$(if $(wildcard apps/$(app).mk apps/$(app)/$(app).mk), \
|
||||
$(if $($(call UPPERCASE,$(APP))_REPOSITORY_URL), \
|
||||
$(call app-install) \
|
||||
$(call app-bootstrap) \
|
||||
,$(call WARNING,Unable to find app,$(app),in dir,$(RELATIVE)$(app)) \
|
||||
|
|
119
make/def.app.mk
119
make/def.app.mk
|
@ -3,11 +3,14 @@ MAKECMDARGS += app-%-exec app-%-run
|
|||
# function app-attach: Call docker-attach for each Dockerfile in dir 1
|
||||
define app-attach
|
||||
$(call INFO,app-attach,$(1)$(comma))
|
||||
$(call docker-file,$(1))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,logs -f $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-attach)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-bootstrap: Define custom variables for app 1 in dir 2 with name 3 and type 4
|
||||
|
@ -21,6 +24,7 @@ define app-bootstrap
|
|||
$(eval DOCKER_BUILD_DIR := $(APP_DIR))
|
||||
$(call compose-file,$(APP_DIR) $(APP_DIR)/$(or $(APP_DOCKER_DIR),$(DOCKER_DIR)),docker-compose)
|
||||
$(call compose-file,apps apps/$(APP),$(APP))
|
||||
$(eval APP_COMPOSE_FILE := $(COMPOSE_FILE))
|
||||
$(foreach stackz,$(STACK),$(call docker-stack,$(stackz)))
|
||||
$(call compose-file,$(MYOS_STACK),$(MYOS_STACK_FILE))
|
||||
$(call .env,$(APP_DIR)/.env,$(APP_DIR)/.env.dist $(APP_DIR)/.env.example $(APP_DIR)/.env.sample)
|
||||
|
@ -29,27 +33,50 @@ endef
|
|||
# function app-build: Call docker-build for each Dockerfile in dir 1
|
||||
define app-build
|
||||
$(call INFO,app-build,$(1)$(comma))
|
||||
$(call docker-file,$(1))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,build $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-build, $(dir $(dockerfile)), $(DOCKER_IMAGE), "" )
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-clean: Remove docker images and volumes for each Dockerfile in dir 1
|
||||
define app-clean
|
||||
$(call INFO,app-clean,$(1)$(comma))
|
||||
$(eval DOCKER_COMPOSE_DOWN_OPTIONS += --rmi all --volumes)
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-rm)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-config: Call docker-compose config with each docker-compose.yml in dir 1
|
||||
define app-config
|
||||
$(call INFO,app-config,$(1)$(comma))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,config)
|
||||
, $(call WARNING,Unable to find a file docker-compose.yml in dir,$(APP_DIR)) \
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-connect: Call docker exec $(DOCKER_SHELL) for each Dockerfile in dir 1
|
||||
define app-connect
|
||||
$(call INFO,app-connect,$(1)$(comma))
|
||||
$(call docker-file,$(1))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,exec $(or $(SERVICE),$(DOCKER_SERVICE)) $(DOCKER_SHELL))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-connect)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-docker: Define custom variables for Dockerfile 1
|
||||
|
@ -71,23 +98,28 @@ endef
|
|||
# function app-down: Call docker rm for each Dockerfile in dir 1
|
||||
define app-down
|
||||
$(call INFO,app-down,$(1)$(comma))
|
||||
$(if $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS)),
|
||||
$(call docker-file,$(1))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-rm)
|
||||
))
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-exec: Call docker exec $(ARGS) for each Dockerfile in dir 1
|
||||
define app-exec
|
||||
$(call INFO,app-exec,$(1)$(comma) $(2))
|
||||
$(call docker-file,$(1))
|
||||
$(eval args := $(or $(2), $(ARGS)))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,exec $(or $(SERVICE),$(DOCKER_SERVICE)) $(args))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call exec,$(args))
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-install: Run 'git clone url 1 dir 2'
|
||||
|
@ -104,23 +136,28 @@ endef
|
|||
# function app-logs: Call docker logs $(ARGS) for each Dockerfile in dir 1
|
||||
define app-logs
|
||||
$(call INFO,app-logs,$(1)$(comma) $(2))
|
||||
$(if $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,logs $(DOCKER_COMPOSE_LOGS_OPTIONS)),
|
||||
$(call docker-file,$(1))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,logs $(DOCKER_COMPOSE_LOGS_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-logs)
|
||||
))
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-ps: Call docker ps for each Dockerfile in dir 1
|
||||
define app-ps
|
||||
$(call INFO,app-ps,$(1)$(comma))
|
||||
$(call docker-file,$(1))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,ps $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(eval DOCKERS += $(DOCKER_NAME))
|
||||
)
|
||||
$(RUN) docker ps $(patsubst %,-f name=%,$(DOCKERS)) 2>/dev/null
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-rebuild: Call app-build with DOCKER_BUILD_CACHE=false
|
||||
|
@ -130,12 +167,24 @@ define app-rebuild
|
|||
$(call app-build,$(1))
|
||||
endef
|
||||
|
||||
# function app-restart: Call app-stop and app-start
|
||||
define app-restart
|
||||
$(call INFO,app-restart,$(1)$(comma))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,restart $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call app-stop,$(1)) # NEED FIX
|
||||
$(call app-start,$(1))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-run: Call docker-run for each Dockerfile in dir 1 with args 2
|
||||
define app-run
|
||||
$(call INFO,app-run,$(1)$(comma) $(2))
|
||||
$(call docker-file,$(1))
|
||||
$(eval args := $(or $(2), $(ARGS)))
|
||||
$(eval DOCKER_RUN_OPTIONS += -it)
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,run $(DOCKER_RUN_OPTIONS) $(or $(SERVICE),$(DOCKER_SERVICE)) $(args))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(if $(shell docker images -q $(DOCKER_IMAGE) 2>/dev/null),
|
||||
|
@ -143,17 +192,55 @@ define app-run
|
|||
, $(call ERROR,Unable to find docker image,$(DOCKER_IMAGE))
|
||||
)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-scale: Call docker-compose scale in dir 1
|
||||
define app-scale
|
||||
$(call INFO,app-scale,$(1)$(comma))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) --scale $(or $(SERVICE),$(DOCKER_SERVICE))=$(NUM))
|
||||
, $(call WARNING,Unable to find a file docker-compose.yml in dir,$(APP_DIR)) \
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-start: Call docker start for each Dockerfile in dir 1
|
||||
define app-start
|
||||
$(call INFO,app-start,$(1)$(comma))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,start $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-start)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-stop: Call docker stop for each Dockerfile in dir 1
|
||||
define app-stop
|
||||
$(call INFO,app-stop,$(1)$(comma))
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,stop $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(call docker-file,$(1))
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-stop)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-up: Call docker-run (-d) for each Dockerfile in dir 1
|
||||
define app-up
|
||||
$(call INFO,app-up,$(1)$(comma))
|
||||
$(eval DOCKER_RUN_OPTIONS += -d)
|
||||
$(if $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS)),
|
||||
$(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
|
||||
$(eval DOCKER_RUN_OPTIONS := -d)
|
||||
$(if $(APP_COMPOSE_FILE),
|
||||
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
, $(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
|
||||
$(call INFO,docker $(DOCKER_NAME) already running)
|
||||
, $(call app-run,$(1))
|
||||
))
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-update: Run 'cd dir 1 && git pull' or Call app-install
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
DOCKER_DIR ?= *
|
||||
DOCKER_DIR ?= docker
|
||||
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
|
||||
|
@ -165,9 +165,14 @@ define docker-file
|
|||
)
|
||||
endef
|
||||
|
||||
# function docker-exited: Print exited dockers matching DOCKER_NAME
|
||||
define docker-exited
|
||||
$(shell docker ps -q -f status=exited $(patsubst %,-f name=%,$(or $(1), ^$(DOCKER_NAME)$$, ^$)) 2>/dev/null)
|
||||
endef
|
||||
|
||||
# function docker-running: Print running dockers matching DOCKER_NAME
|
||||
define docker-running
|
||||
$(shell docker ps -q $(patsubst %,-f name=%,$(or $(1), ^$(DOCKER_NAME)$$, ^$)) 2>/dev/null)
|
||||
$(shell docker ps -q -f status=running $(patsubst %,-f name=%,$(or $(1), ^$(DOCKER_NAME)$$, ^$)) 2>/dev/null)
|
||||
endef
|
||||
|
||||
# function docker-rm: Remove docker 1
|
||||
|
@ -180,6 +185,29 @@ define docker-rm
|
|||
$(RUN) docker rm -f $(rm)
|
||||
endef
|
||||
|
||||
# function docker-start: Start docker 1
|
||||
define docker-start
|
||||
$(call INFO,docker-start,$(1)$(comma))
|
||||
$(eval start := $(or $(1),$(DOCKER_NAME)))
|
||||
$(if $(call docker-running,^$(start)$),
|
||||
$(call WARNING,docker,$(start),is already running)
|
||||
, $(if $(call docker-exited,^$(start)$),
|
||||
$(RUN) docker start $(start)
|
||||
, $(call WARNING,Unable to find docker,$(start),in state exited)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# function docker-stop: Stop docker 1
|
||||
define docker-stop
|
||||
$(call INFO,docker-stop,$(1)$(comma))
|
||||
$(eval stop := $(or $(1),$(DOCKER_NAME)))
|
||||
$(if $(call docker-running,^$(stop)$),
|
||||
$(RUN) docker stop $(stop)
|
||||
, $(call WARNING,docker,$(stop),is not running)
|
||||
)
|
||||
endef
|
||||
|
||||
# function docker-volume-copy: Copy files from a docker volume to another
|
||||
define docker-volume-copy
|
||||
$(call INFO,docker-volume-copy,$(1)$(comma) $(2))
|
||||
|
|
|
@ -78,7 +78,7 @@ INSTALL_CMDS ?= APK_INSTALL APT_INSTALL
|
|||
$(foreach cmd,$(INSTALL_CMDS),$(if $(CMD_$(cmd)),$(eval INSTALL_CMD ?= $(CMD_$(cmd)))))
|
||||
LOG_LEVEL ?= $(if $(DEBUG),debug,$(if $(VERBOSE),info,error))
|
||||
MAIL ?= $(GIT_AUTHOR_EMAIL)
|
||||
MAKE_ARGS ?= $(foreach var,$(MAKE_VARS),$(if $($(var)),$(var)='$($(var))'))
|
||||
MAKE_ARGS = $(foreach var,$(MAKE_VARS),$(if $($(var)),$(var)='$($(var))'))
|
||||
MAKE_SUBDIRS ?= $(if $(filter myos,$(MYOS)),monorepo,$(if $(APP),apps $(foreach type,$(APP_LOAD),$(if $(wildcard $(MAKE_DIR)/apps/$(type)),apps/$(type)))))
|
||||
MAKE_CMD_ARGS ?= $(foreach var,$(MAKE_CMD_VARS),$(var)='$($(var))')
|
||||
MAKE_CMD_VARS ?= $(strip $(foreach var, $(filter-out .VARIABLES,$(.VARIABLES)), $(if $(filter command\ line,$(origin $(var))),$(var))))
|
||||
|
@ -90,7 +90,7 @@ MAKE_OLDFILE ?= $@
|
|||
MAKE_TARGETS ?= $(filter-out $(.VARIABLES),$(shell $(MAKE) -qp 2>/dev/null |awk -F':' '/^[a-zA-Z0-9][^$$\#\/\t=]*:([^=]|$$)/ {print $$1}' 2>/dev/null |sort -u))
|
||||
MAKE_UNIXTIME_START := $(shell date -u +'%s' 2>/dev/null)
|
||||
MAKE_UNIXTIME_CURRENT = $(shell date -u "+%s" 2>/dev/null)
|
||||
MAKE_VARS ?= ENV DOCKER_COMPOSE DOCKER_MACHINE DOCKER_SYSTEM
|
||||
MAKE_VARS := ENV COMPOSE_FILE DOCKER_COMPOSE DOCKER_MACHINE DOCKER_SERVICES DOCKER_SYSTEM
|
||||
MAKECMDARGS ?= apps-install install-app
|
||||
MONOREPO ?= $(if $(filter myos,$(MYOS)),$(notdir $(CURDIR)),$(if $(APP),$(notdir $(realpath $(CURDIR)/..))))
|
||||
MONOREPO_DIR ?= $(if $(MONOREPO),$(if $(filter myos,$(MYOS)),$(realpath $(CURDIR)),$(if $(APP),$(realpath $(CURDIR)/..))))
|
||||
|
|
|
@ -18,7 +18,7 @@ contexts: $(foreach var,$(CONTEXT),context-$(var))
|
|||
|
||||
# target context-% print-%: Print % value
|
||||
.PHONY: context-% print-%
|
||||
context-% print-%:
|
||||
context-% print-%: stack
|
||||
@printf "${COLOR_HIGHLIGHT}%-37s${COLOR_RESET}" $*
|
||||
@printf "${COLOR_VALUE}"
|
||||
@$(call PRINTF,$($*))
|
||||
|
|
|
@ -12,15 +12,15 @@ MAKE_LATEST := $(MAKE_DIR)/end.mk
|
|||
|
||||
## it includes $(MAKE_FIRST)
|
||||
include $(wildcard $(MAKE_FIRST))
|
||||
## it includes $(MAKE_DIR)/*/def.mk $(MAKE_DIR)/*/def.*.mk
|
||||
## it includes $(MAKE_DIR)/$(MAKE_SUBDIRS)/def.mk $(MAKE_DIR)/$(MAKE_SUBDIRS)/def.*.mk
|
||||
include $(foreach subdir,$(MAKE_SUBDIRS),$(wildcard $(MAKE_DIR)/$(subdir)/def.mk $(MAKE_DIR)/$(subdir)/def.*.mk))
|
||||
## it includes def.mk def.*.mk */def.mk */def.*.mk if not myos nor monorepo
|
||||
## if not in $(MYOS) nor $(MONOREPO), it includes def.mk def.*.mk */def.mk */def.*.mk
|
||||
include $(if $(filter-out . myos,$(MYOS)),$(wildcard def.mk def.*.mk */def.mk */def.*.mk))
|
||||
## it includes $(MAKE_DIR)/*.mk
|
||||
include $(filter-out $(wildcard $(MAKE_FILE) $(MAKE_FIRST) $(MAKE_LATEST)),$(wildcard $(MAKE_DIR)/*.mk))
|
||||
## it includes $(MAKE_DIR)/*/*.mk
|
||||
## it includes $(MAKE_DIR)/$(MAKE_SUBDIRS)/*.mk
|
||||
include $(foreach subdir,$(MAKE_SUBDIRS),$(filter-out $(wildcard $(MAKE_DIR)/$(subdir)/def.mk $(MAKE_DIR)/$(subdir)/def.*.mk),$(wildcard $(MAKE_DIR)/$(subdir)/*.mk)))
|
||||
## it includes *.mk */*.mk if not myos nor monorepo, stack/*.mk if myos
|
||||
## if not in $(MYOS) nor $(MONOREPO), it includes *.mk */*.mk, else stack/*.mk if in $(MYOS)
|
||||
include $(if $(filter-out myos,$(MYOS)),$(if $(filter-out .,$(MYOS)),$(filter-out $(wildcard def.mk def.*.mk */def.mk */def.*.mk),$(wildcard *.mk */*.mk)),$(wildcard stack/*.mk stack/*/*.mk)))
|
||||
## it includes $(MAKE_LATEST)
|
||||
include $(wildcard $(MAKE_LATEST))
|
||||
|
|
Loading…
Reference in New Issue