doc
This commit is contained in:
+25
-31
@@ -1,46 +1,40 @@
|
||||
##
|
||||
# BUILD
|
||||
|
||||
# target build: Build application docker images on local host
|
||||
.PHONY: build
|
||||
build: docker-compose-build ## Build application docker images
|
||||
|
||||
# target build@%: Build application docker images to deploy
|
||||
.PHONY: build@% app-build
|
||||
build@%: myos-base
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
$(eval SERVICES ?= $(shell $(call docker-compose,--log-level critical config --services)))
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(eval docker_images += $(foreach service,$(SERVICES),$(if $(shell docker images -q $(DOCKER_REPOSITORY)/$(service):$(DOCKER_IMAGE_TAG) 2>/dev/null),$(service))))
|
||||
$(eval build_app := $(or $(filter $(DOCKER_BUILD_CACHE),false),$(filter-out $(docker_images),$(SERVICES))))
|
||||
$(if $(build_app),$(call make,build-init app-build),$(if $(filter $(VERBOSE),true),$(foreach service,$(SERVICES),echo "docker image $(DOCKER_REPOSITORY)/$(service):$(DOCKER_IMAGE_TAG) has id $(shell docker images -q $(DOCKER_REPOSITORY)/$(service):$(DOCKER_IMAGE_TAG) 2>/dev/null)" &&) true))
|
||||
|
||||
# target build-env: Build .env file in docker $(SERVICE) to deploy
|
||||
# target build-env: Build .env file in docker SERVICE to deploy
|
||||
# on local host
|
||||
.PHONY: build-env
|
||||
build-env: SERVICE ?= $(DOCKER_SERVICE)
|
||||
build-env: bootstrap
|
||||
$(call docker-compose-exec,$(SERVICE),rm -f .env && make .env ENV=$(ENV) && echo BUILD=true >> .env && echo BUILD_DATE='"\'"'$(shell date "+%d/%m/%Y %H:%M:%S %z" 2>/dev/null)'"\'"' >> .env && echo BUILD_STATUS='"\'"'$(shell git status -uno --porcelain 2>/dev/null)'"\'"' >> .env && echo DOCKER=false >> .env && $(foreach var,$(BUILD_ENV_VARS),$(if $($(var)),sed -i '/^$(var)=/d' .env && echo $(var)='$($(var))' >> .env &&)) true)
|
||||
$(call docker-compose-exec,$(SERVICE), \
|
||||
rm -f .env \
|
||||
&& make .env ENV=$(ENV) \
|
||||
&& echo BUILD=true >> .env \
|
||||
&& echo BUILD_DATE='"\'"'$(shell date "+%d/%m/%Y %H:%M:%S %z" 2>/dev/null)'"\'"' >> .env \
|
||||
&& echo BUILD_STATUS='"\'"'$(shell git status -uno --porcelain 2>/dev/null)'"\'"' >> .env \
|
||||
&& echo DOCKER=false >> .env \
|
||||
&& $(foreach var,$(BUILD_ENV_VARS), \
|
||||
$(if $($(var)),sed -i '/^$(var)=/d' .env && echo $(var)='$($(var))' >> .env &&) \
|
||||
) true \
|
||||
)
|
||||
|
||||
# target build-init: Empty build directory
|
||||
# on local host
|
||||
.PHONY: build-init
|
||||
build-init:
|
||||
$(ECHO) rm -rf build && $(ECHO) mkdir -p build
|
||||
|
||||
# target build-shared: Create shared folder in docker $(SERVICE) to deploy
|
||||
# target build-shared: Create SHARED folder in docker SERVICE to deploy
|
||||
# on local host
|
||||
.PHONY: build-shared
|
||||
build-shared: SERVICE ?= $(DOCKER_SERVICE)
|
||||
build-shared: bootstrap
|
||||
$(call docker-compose-exec,$(SERVICE),mkdir -p /$(notdir $(SHARED)) && $(foreach folder,$(SHARED_FOLDERS),rm -rf $(folder) && mkdir -p $(dir $(folder)) && ln -s /$(notdir $(SHARED))/$(notdir $(folder)) $(folder) &&) true)
|
||||
|
||||
# target rebuild: Rebuild application docker images on local host
|
||||
.PHONY: rebuild
|
||||
rebuild: docker-compose-rebuild ## Rebuild application dockers images
|
||||
|
||||
# target rebuild@%: Rebuild application docker images on local host
|
||||
.PHONY: rebuild@%
|
||||
rebuild@%: ## Rebuild application dockers images
|
||||
$(call make,build@$* DOCKER_BUILD_CACHE=false)
|
||||
|
||||
# target rebuild-images: Rebuild docker/* images
|
||||
.PHONY: rebuild-images
|
||||
rebuild-images: docker-rebuild-images ## Rebuild docker/* images
|
||||
$(call docker-compose-exec,$(SERVICE), \
|
||||
mkdir -p /$(notdir $(SHARED)) \
|
||||
&& $(foreach folder,$(SHARED_FOLDERS), \
|
||||
rm -rf $(folder) \
|
||||
&& mkdir -p $(dir $(folder)) \
|
||||
&& ln -s /$(notdir $(SHARED))/$(notdir $(folder)) $(folder) \
|
||||
&& \
|
||||
) true \
|
||||
)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
##
|
||||
# CLEAN
|
||||
|
||||
.PHONY: clean app-clean
|
||||
clean: app-clean docker-compose-down .env-clean ## Clean application and docker images
|
||||
|
||||
# target clean@%: Clean deployed application and docker images
|
||||
.PHONY: clean@%
|
||||
clean@%:
|
||||
$(call make,docker-compose-down DOCKER_COMPOSE_DOWN_OPTIONS='--rmi all -v')
|
||||
+130
-20
@@ -1,66 +1,155 @@
|
||||
##
|
||||
# COMMON
|
||||
|
||||
# target bootstrap: Update application files and start dockers
|
||||
# on local host
|
||||
.PHONY: bootstrap
|
||||
bootstrap: bootstrap-git bootstrap-docker app-bootstrap ## Bootstrap application
|
||||
bootstrap: bootstrap-git bootstrap-docker app-bootstrap ## Update application files and start dockers
|
||||
|
||||
# target bootstrap-docker: Build and start application dockers
|
||||
# on local host
|
||||
.PHONY: boostrap-docker
|
||||
bootstrap-docker: docker-network-create
|
||||
$(call make,docker-compose-up)
|
||||
|
||||
# target bootstrap-git: Fire update-app
|
||||
.PHONY: bootstrap-git
|
||||
bootstrap-git: bootstrap-git-$(APP_DIR)
|
||||
bootstrap-git: update-app
|
||||
|
||||
# target bootstrap-git-%: Clone GIT_REPOSITORY in folder %
|
||||
# on local host
|
||||
.PHONY: bootstrap-git-%
|
||||
bootstrap-git-%:
|
||||
if ! git config remote.origin.url > /dev/null ; \
|
||||
then git clone $(GIT_REPOSITORY) $*; \
|
||||
then git clone $(QUIET) $(GIT_REPOSITORY) $*; \
|
||||
fi
|
||||
|
||||
# target build: Build application docker images to run
|
||||
# on local host
|
||||
.PHONY: build
|
||||
build: docker-compose-build ## Build application docker images
|
||||
|
||||
# target build@%: Build application docker images to deploy of % ENV
|
||||
# on local host
|
||||
.PHONY: build@% app-build
|
||||
build@%: myos-base
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
$(eval SERVICES ?= $(shell $(call docker-compose,--log-level critical config --services)))
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(eval docker_images += $(foreach service,$(SERVICES),$(if $(shell docker images -q $(DOCKER_REPOSITORY)/$(service):$(DOCKER_IMAGE_TAG) 2>/dev/null),$(service))))
|
||||
$(eval build_app := $(or $(filter $(DOCKER_BUILD_CACHE),false),$(filter-out $(docker_images),$(SERVICES))))
|
||||
$(if $(build_app), \
|
||||
$(call make,build-init app-build), \
|
||||
$(if $(filter $(VERBOSE),true), \
|
||||
$(foreach service,$(SERVICES), \
|
||||
echo "docker image $(DOCKER_REPOSITORY)/$(service):$(DOCKER_IMAGE_TAG) has id $(shell docker images -q $(DOCKER_REPOSITORY)/$(service):$(DOCKER_IMAGE_TAG) 2>/dev/null)" && \
|
||||
) true \
|
||||
) \
|
||||
)
|
||||
|
||||
# target clean: Clean application and docker images
|
||||
# on local host
|
||||
.PHONY: clean app-clean
|
||||
clean: app-clean docker-compose-down .env-clean ## Clean application and docker images
|
||||
|
||||
# target clean@%: Clean deployed application and docker images of % ENV
|
||||
# on local host
|
||||
.PHONY: clean@%
|
||||
clean@%:
|
||||
$(call make,docker-compose-down DOCKER_COMPOSE_DOWN_OPTIONS='--rmi all -v')
|
||||
|
||||
# target config: View application docker compose file
|
||||
# on local host
|
||||
.PHONY: config
|
||||
config: docker-compose-config ## View docker compose file
|
||||
config: docker-compose-config ## View application docker compose file
|
||||
|
||||
# target connect: Connect to docker SERVICE
|
||||
# on local host
|
||||
.PHONY: connect
|
||||
connect: docker-compose-connect ## Connect to docker $(SERVICE)
|
||||
connect: docker-compose-connect ## Connect to docker SERVICE
|
||||
|
||||
# target connect@%: Connect to docker SERVICE of % ENV
|
||||
# on first remote host
|
||||
.PHONY: connect@%
|
||||
connect@%: SERVICE ?= $(DOCKER_SERVICE)
|
||||
connect@%: ## Connect to docker $(SERVICE) on first remote host
|
||||
connect@%:
|
||||
$(call make,ssh-connect,$(MYOS),APP SERVICE)
|
||||
|
||||
# target deploy: Fire deploy@ENV
|
||||
.PHONY: deploy
|
||||
deploy: deploy@$(ENV) ## Deploy application dockers
|
||||
|
||||
# target down: Remove application dockers
|
||||
# on local host
|
||||
.PHONY: down
|
||||
down: docker-compose-down ## Remove application dockers
|
||||
|
||||
# target exec: Exec command in docker SERVICE
|
||||
# on local host
|
||||
.PHONY: exec
|
||||
exec: ## Exec a command in docker $(SERVICE)
|
||||
exec: ## Exec command in docker SERVICE
|
||||
ifneq (,$(filter $(ENV),$(ENV_DEPLOY)))
|
||||
$(call exec,$(ARGS))
|
||||
else
|
||||
$(call make,docker-compose-exec,,ARGS)
|
||||
endif
|
||||
|
||||
# target exec@%: Exec command in docker SERVICE of % ENV
|
||||
# on all remote hosts
|
||||
.PHONY: exec@%
|
||||
exec@%: SERVICE ?= $(DOCKER_SERVICE)
|
||||
exec@%: ## Exec a command in docker $(SERVICE) on all remote hosts
|
||||
exec@%:
|
||||
$(call make,ssh-exec,$(MYOS),APP ARGS SERVICE)
|
||||
|
||||
# target install app-install: Install application
|
||||
# on local host
|
||||
.PHONY: install app-install
|
||||
install: app-install ## Install application
|
||||
|
||||
# target logs: Display application dockers logs
|
||||
# on local host
|
||||
.PHONY: logs
|
||||
logs: docker-compose-logs ## Display application dockers logs
|
||||
|
||||
# target ps: List application dockers
|
||||
# on local host
|
||||
.PHONY: ps
|
||||
ps: docker-compose-ps ## List application dockers
|
||||
|
||||
# target rebuild: Rebuild application docker images
|
||||
# on local host
|
||||
.PHONY: rebuild
|
||||
rebuild: docker-compose-rebuild ## Rebuild application dockers images
|
||||
|
||||
# target rebuild@%: Rebuild application docker images
|
||||
# on local host
|
||||
.PHONY: rebuild@%
|
||||
rebuild@%:
|
||||
$(call make,build@$* DOCKER_BUILD_CACHE=false)
|
||||
|
||||
# target recreate: Recreate application dockers
|
||||
# on local host
|
||||
.PHONY: recreate
|
||||
recreate: docker-compose-recreate app-start ## Recreate application dockers
|
||||
|
||||
# target reinstall: Fire clean and call install target
|
||||
# on local host
|
||||
.PHONY: reinstall
|
||||
reinstall: clean ## Reinstall application
|
||||
$(call make,.env)
|
||||
$(call make,install)
|
||||
|
||||
# target release: Fire release-create
|
||||
.PHONY: release
|
||||
release: release-create ## Create release VERSION
|
||||
|
||||
# target restart: Restart application dockers
|
||||
# on local host
|
||||
.PHONY: restart
|
||||
restart: docker-compose-restart app-start ## Restart application
|
||||
|
||||
# target run: Run command in a new docker SERVICE
|
||||
# on local host
|
||||
.PHONY: run
|
||||
run: ## Run a command in a new docker
|
||||
ifneq (,$(filter $(ENV),$(ENV_DEPLOY)))
|
||||
@@ -69,27 +158,34 @@ else
|
||||
$(call make,docker-compose-run,,ARGS)
|
||||
endif
|
||||
|
||||
# target run@%: Run command in a new docker SERVICE of % ENV
|
||||
# on all remote hosts
|
||||
.PHONY: run@%
|
||||
run@%: SERVICE ?= $(DOCKER_SERVICE)
|
||||
run@%: ## Run a command on all remote hosts
|
||||
run@%:
|
||||
$(call make,ssh-run,$(MYOS),APP ARGS)
|
||||
|
||||
# target scale: Scale SERVICE application to NUM dockers
|
||||
# on local host
|
||||
.PHONY: scale
|
||||
scale: docker-compose-scale ## Scale application to NUM dockers
|
||||
scale: docker-compose-scale ## Scale SERVICE application to NUM dockers
|
||||
|
||||
# target ssh@%: Connect to % ENV
|
||||
# on first remote host
|
||||
.PHONY: ssh@%
|
||||
ssh@%: ## Connect to first remote host
|
||||
ssh@%:
|
||||
$(call make,ssh,$(MYOS),APP)
|
||||
|
||||
# target stack: Call docker-stack function with each value of $(STACK)
|
||||
# target stack: Call docker-stack for each STACK
|
||||
## it updates COMPOSE_FILE with all .yml files of the current stack
|
||||
.PHONY: stack
|
||||
stack:
|
||||
$(foreach stackz,$(STACK),$(call docker-stack,$(stackz)))
|
||||
|
||||
# target stack-%: Call docker-compose-* command on a given stack
|
||||
## ex: calling stack-base-up will fire the docker-compose-up target on the base stack
|
||||
## it splits $* on dashes and extracts stack from the beginning of $* and command
|
||||
## from the last part of $*
|
||||
# target stack-%: Call docker-compose-% target on a given stack
|
||||
## it splits % on dashes and extracts stack from the beginning and command from
|
||||
## the last part of %
|
||||
## ex: stack-base-up will fire the docker-compose-up target in the base stack
|
||||
.PHONY: stack-%
|
||||
stack-%:
|
||||
$(eval stack := $(subst -$(lastword $(subst -, ,$*)),,$*))
|
||||
@@ -98,26 +194,40 @@ stack-%:
|
||||
$(if $(filter $(command),$(filter-out %-%,$(patsubst docker-compose-%,%,$(filter docker-compose-%,$(MAKE_TARGETS))))), \
|
||||
$(call make,docker-compose-$(command) STACK="$(stack)" $(if $(filter node,$(stack)),COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_NODE)),,ARGS COMPOSE_IGNORE_ORPHANS SERVICE)))
|
||||
|
||||
# target start: Start application dockers
|
||||
# on local host
|
||||
.PHONY: start
|
||||
start: docker-compose-start ## Start application dockers
|
||||
|
||||
# target stop: Stop application dockers
|
||||
# on local host
|
||||
.PHONY: stop
|
||||
stop: docker-compose-stop ## Stop application dockers
|
||||
|
||||
# target tests app-tests: Test application
|
||||
# on local host
|
||||
.PHONY: tests app-tests
|
||||
tests: app-tests ## Test application
|
||||
|
||||
# target up: Create and start application dockers
|
||||
# on local host
|
||||
.PHONY: up
|
||||
up: docker-compose-up app-start ## Create application dockers
|
||||
|
||||
# target update app-update: Update application files
|
||||
# on local host
|
||||
.PHONY: update app-update
|
||||
update: update-app app-update ## Update application
|
||||
update: update-app app-update ## Update application files
|
||||
|
||||
# target upgrade app-upgrade: Upgrade application
|
||||
# on local host
|
||||
.PHONY: upgrade app-upgrade
|
||||
upgrade: update app-upgrade release-upgrade ## Upgrade application
|
||||
|
||||
# target %: Always fired target
|
||||
## this target is fired everytime make is runned to call the stack target and
|
||||
## update COMPOSE_FILE variable with all .yml files of the current project stack
|
||||
## it fires the stack and %-rule-exists targets everytime
|
||||
%: FORCE stack %-rule-exists ;
|
||||
|
||||
# target %-rule-exists: Print a warning message if $* target does not exists
|
||||
# target %-rule-exists: Print a warning message if % target does not exists
|
||||
%-rule-exists:
|
||||
$(if $(filter $*,$(MAKECMDGOALS)),$(if $(filter-out $*,$(MAKE_TARGETS)),printf "${COLOR_BROWN}WARNING${COLOR_RESET}: ${COLOR_GREEN}target${COLOR_RESET} $* ${COLOR_GREEN}not available in app${COLOR_RESET} $(APP).\n" >&2))
|
||||
|
||||
@@ -72,9 +72,11 @@ endif
|
||||
|
||||
ifeq ($(DOCKER), true)
|
||||
|
||||
# function docker-compose: Run docker-compose with arg 1
|
||||
define docker-compose
|
||||
$(call run,docker/compose:$(COMPOSE_VERSION) $(patsubst %,-f %,$(COMPOSE_FILE)) -p $(COMPOSE_PROJECT_NAME) $(1))
|
||||
endef
|
||||
# function docker-compose-exec: Run docker-compose-exec with arg 2 in service 1
|
||||
define docker-compose-exec
|
||||
$(call run,docker/compose:$(COMPOSE_VERSION) $(patsubst %,-f %,$(COMPOSE_FILE)) -p $(COMPOSE_PROJECT_NAME) exec -T $(1) sh -c '$(2)')
|
||||
endef
|
||||
@@ -91,6 +93,7 @@ endef
|
||||
|
||||
endif
|
||||
|
||||
# function docker-build: Build docker image
|
||||
define docker-build
|
||||
$(eval path := $(patsubst %/,%,$(1)))
|
||||
$(eval tag := $(or $(2),$(DOCKER_REPOSITORY)/$(lastword $(subst /, ,$(path))):$(DOCKER_IMAGE_TAG)))
|
||||
@@ -99,6 +102,7 @@ define docker-build
|
||||
$(eval build_image := $(or $(filter $(DOCKER_BUILD_CACHE),false),$(if $(image_id),,true)))
|
||||
$(if $(build_image),$(ECHO) docker build $(DOCKER_BUILD_ARGS) --build-arg DOCKER_BUILD_DIR="$(path)" --tag $(tag) $(if $(target),--target $(target)) -f $(path)/Dockerfile .,$(if $(filter $(VERBOSE),true),echo "docker image $(tag) has id $(image_id)",true))
|
||||
endef
|
||||
# function docker-commit: Commit docker image
|
||||
define docker-commit
|
||||
$(eval service := $(or $(1),$(DOCKER_SERVICE)))
|
||||
$(eval container := $(or $(2),$(firstword $(shell $(call docker-compose,--log-level critical ps -q $(service))))))
|
||||
@@ -107,6 +111,7 @@ define docker-commit
|
||||
$(if $(filter $(VERBOSE),true),echo docker commit $(container) $(repository):$(tag))
|
||||
$(ECHO) docker commit $(container) $(repository):$(tag)
|
||||
endef
|
||||
# function docker-push: Push docker image
|
||||
define docker-push
|
||||
$(eval service := $(or $(1),$(DOCKER_SERVICE)))
|
||||
$(eval name := $(or $(2),$(DOCKER_REGISTRY_REPOSITORY)/$(service)))
|
||||
@@ -114,8 +119,7 @@ define docker-push
|
||||
$(if $(filter $(VERBOSE),true),echo docker push $(name):$(tag))
|
||||
$(ECHO) docker push $(name):$(tag)
|
||||
endef
|
||||
##
|
||||
# docker-stack
|
||||
# function docker-stack: Call itself recursively for each stack to expand stacks
|
||||
# docker-stack: if 1st arg is a variable and can be expand to values, it calls
|
||||
# itself again, once whith each value, else calls docker-stack-update function
|
||||
# 1st arg: stacks, extract it from stack_names:stack_versions
|
||||
@@ -125,8 +129,7 @@ define docker-stack
|
||||
$(eval versions := $(or $(if $(findstring :,$(1)),$(lastword $(subst :, ,$(1)))),$(2)))
|
||||
$(if $($(stacks)),$(foreach substack,$($(stacks)),$(call docker-stack,$(substack),$(if $(findstring :,$(1)),$(versions)))),$(call docker-stack-update,$(stacks),$(versions)))
|
||||
endef
|
||||
##
|
||||
# docker-stack-update
|
||||
# function docker-stack-update: Update COMPOSE_FILE with .yml files of the stack
|
||||
# docker-stack-update: adds all .yml files of the stack to COMPOSE_FILE variable
|
||||
# and update the .env file with the .env.dist files of the stack
|
||||
# 1st arg: stack_path/stack_name:stack_version
|
||||
@@ -144,6 +147,7 @@ define docker-stack-update
|
||||
$(eval COMPOSE_FILE += $(wildcard $(path)/$(name).yml $(path)/$(name).$(ENV).yml $(path)/$(name).$(ENV).$(version).yml $(path)/$(name).$(version).yml))
|
||||
$(if $(wildcard $(path)/.env.dist),$(call .env,,$(path)/.env.dist,$(wildcard $(PARAMETERS)/$(ENV)/$(APP)/.env $(path)/.env.$(ENV) .env)))
|
||||
endef
|
||||
# function docker-tag: Tag docker image
|
||||
define docker-tag
|
||||
$(eval service := $(or $(1),$(DOCKER_SERVICE)))
|
||||
$(eval source := $(or $(2),$(DOCKER_REPOSITORY)/$(service)))
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# function install-parameters: copy PARAMETERS files to application config folder
|
||||
define install-parameters
|
||||
$(eval path:=$(or $(1),$(APP)))
|
||||
$(eval file:=$(or $(2),$(DOCKER_SERVICE)/parameters.yml))
|
||||
$(eval dest:=$(or $(3),app/config))
|
||||
$(eval file:=$(or $(2),$(DOCKER_SERVICE)))
|
||||
$(eval dest:=$(or $(3),config))
|
||||
$(eval env:=$(or $(4),$(ENV)))
|
||||
$(if $(wildcard $(dest)/$(file)),,$(if $(wildcard $(PARAMETERS)/$(env)/$(path)/$(file)),$(ECHO) cp -a $(PARAMETERS)/$(env)/$(path)/$(file) $(dest)))
|
||||
endef
|
||||
|
||||
+19
-14
@@ -1,24 +1,29 @@
|
||||
##
|
||||
# DEPLOY
|
||||
|
||||
.PHONY: deploy app-deploy
|
||||
# target deploy: Run post install hooks in the deployed application
|
||||
## Called by ansible after creation of the docker application on remote host
|
||||
deploy: app-deploy deploy-ping ## Run post install hooks in the deployed application
|
||||
|
||||
.PHONY: deploy@%
|
||||
# target deploy@%: Deploy application docker images
|
||||
## tag and push docker images to docker registry
|
||||
## run ansible-pull on hosts to pull docker images from the registry
|
||||
## tag and push docker images as latest to docker registry
|
||||
## it tags and pushes docker images to docker registry
|
||||
## it runs ansible-pull on hosts to pull docker images from the registry
|
||||
## it tags and pushes docker images as latest to docker registry
|
||||
.PHONY: deploy@%
|
||||
deploy@%: myos-base build@% ## Deploy application docker images
|
||||
$(call make,docker-login docker-tag docker-push)
|
||||
$(call make,myos-ansible-pull@$(ENV) ANSIBLE_DOCKER_IMAGE_TAG=$(VERSION) ANSIBLE_TAGS=aws,,APP AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY)
|
||||
$(call make,docker-tag-latest docker-push-latest)
|
||||
|
||||
.PHONY: deploy-ping
|
||||
deploy-ping: deploy-ping-hook
|
||||
# target deploy-hook: Fire app-deploy deploy-hook-ping
|
||||
## it is called by ansible in the application dockers launched on remote hosts
|
||||
.PHONY: deploy-hook app-deploy
|
||||
deploy-hook: app-deploy deploy-hook-ping
|
||||
|
||||
.PHONY: deploy-ping-hook
|
||||
deploy-ping-hook:
|
||||
curl -X POST --data-urlencode 'payload={"text": "$(DEPLOY_HOOK_TEXT)"}' $(DEPLOY_HOOK_URL) ||:
|
||||
# target deploy-hook-ping: Fire deploy-hook-ping-curl
|
||||
.PHONY: deploy-hook-ping
|
||||
deploy-hook-ping: deploy-hook-ping-curl
|
||||
|
||||
# target deploy-hook-ping-curl: Post install hook to curl DEPLOY_HOOK_URL
|
||||
.PHONY: deploy-hook-ping-curl
|
||||
deploy-hook-ping-curl:
|
||||
$(if $(DEPLOY_HOOK_URL),$(ECHO) curl -X POST --data-urlencode \
|
||||
'payload={"text": "$(DEPLOY_HOOK_TEXT)"}' \
|
||||
$(DEPLOY_HOOK_URL) \
|
||||
||: )
|
||||
|
||||
+42
-1
@@ -1,10 +1,12 @@
|
||||
##
|
||||
# DOCKER
|
||||
|
||||
# target docker-build: Fire docker-images-myos and call docker-build-% target for each DOCKER_IMAGES
|
||||
.PHONY: docker-build
|
||||
docker-build: docker-images-myos
|
||||
$(foreach image,$(or $(SERVICE),$(DOCKER_IMAGES)),$(call make,docker-build-$(image)))
|
||||
|
||||
# target docker-build-%: Call docker-build for each Dockerfile in docker/% folder
|
||||
.PHONY: docker-build-%
|
||||
docker-build-%:
|
||||
if grep -q DOCKER_REPOSITORY docker/$*/Dockerfile 2>/dev/null; then $(eval DOCKER_BUILD_ARGS:=$(subst $(DOCKER_REPOSITORY),$(DOCKER_REPOSITORY_MYOS),$(DOCKER_BUILD_ARGS))) true; fi
|
||||
@@ -12,6 +14,7 @@ docker-build-%:
|
||||
$(if $(findstring :,$*),$(eval DOCKERFILES := $(wildcard docker/$(subst :,/,$*)/Dockerfile)),$(eval DOCKERFILES := $(wildcard docker/$*/*/Dockerfile)))
|
||||
$(foreach dockerfile,$(DOCKERFILES),$(call docker-build,$(dir $(dockerfile)),$(DOCKER_REPOSITORY)/$(word 2,$(subst /, ,$(dir $(dockerfile)))):$(lastword $(subst /, ,$(dir $(dockerfile)))),"") && true)
|
||||
|
||||
# target docker-commit: Call docker-commit for each SERVICES
|
||||
.PHONY: docker-commit
|
||||
docker-commit:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -19,6 +22,7 @@ docker-commit:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(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-%:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -26,6 +30,7 @@ docker-commit-%:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-commit,$(service),,,$*))
|
||||
|
||||
# target docker-compose-build: Fire docker-images-myos and call docker-compose build SERVICE
|
||||
.PHONY: docker-compose-build
|
||||
docker-compose-build: docker-images-myos
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -33,15 +38,18 @@ docker-compose-build: docker-images-myos
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(call docker-compose,build $(if $(filter $(DOCKER_BUILD_NO_CACHE),true),--pull --no-cache) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-config: Call docker-compose config
|
||||
.PHONY: docker-compose-config
|
||||
docker-compose-config:
|
||||
$(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:
|
||||
$(call docker-compose,exec $(SERVICE) $(DOCKER_SHELL)) || true
|
||||
|
||||
# target docker-compose-down: Call docker-compose rm SERVICE or docker-compose down
|
||||
.PHONY: docker-compose-down
|
||||
docker-compose-down:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -49,11 +57,13 @@ docker-compose-down:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(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:
|
||||
$(call docker-compose-exec,$(SERVICE),$(ARGS)) || true
|
||||
|
||||
# target docker-compose-logs: Call docker-compose logs SERVICE
|
||||
.PHONY: docker-compose-logs
|
||||
docker-compose-logs:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -61,17 +71,21 @@ docker-compose-logs:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(call docker-compose,logs -f --tail=100 $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE))) || true
|
||||
|
||||
# target docker-compose-ps: Call docker-compose ps
|
||||
.PHONY: docker-compose-ps
|
||||
docker-compose-ps:
|
||||
$(call docker-compose,ps)
|
||||
|
||||
# target docker-compose-rebuild: Call docker-compose-build target with DOCKER_BUILD_NO_CACHE=true
|
||||
.PHONY: docker-compose-rebuild
|
||||
docker-compose-rebuild: docker-images-myos
|
||||
docker-compose-rebuild:
|
||||
$(call make,docker-compose-build DOCKER_BUILD_NO_CACHE=true)
|
||||
|
||||
# target docker-compose-recreate: Fire docker-compose-rm docker-compose-up
|
||||
.PHONY: docker-compose-recreate
|
||||
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:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -79,6 +93,7 @@ docker-compose-restart:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(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:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -86,16 +101,19 @@ docker-compose-rm:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(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:
|
||||
$(call docker-compose,run $(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:
|
||||
$(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:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -103,6 +121,7 @@ docker-compose-start:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(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:
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -110,6 +129,7 @@ docker-compose-stop:
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(call docker-compose,stop $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
|
||||
|
||||
# target docker-compose-up: Fire docker-image-myos and call docker-compose up SERVICE
|
||||
.PHONY: docker-compose-up
|
||||
docker-compose-up: docker-images-myos
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
@@ -117,43 +137,53 @@ docker-compose-up: docker-images-myos
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(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
|
||||
.PHONY: docker-images-myos
|
||||
docker-images-myos:
|
||||
$(foreach image,$(subst $(quote),,$(DOCKER_IMAGES_MYOS)),$(call make,myos-docker-build-$(image)))
|
||||
|
||||
# target docker-images-rm: Call docker-image-rm-% target for DOCKER_REPOSITORY
|
||||
.PHONY: docker-images-rm
|
||||
docker-images-rm:
|
||||
$(call make,docker-images-rm-$(DOCKER_REPOSITORY)/)
|
||||
|
||||
# target docker-images-rm-%: Remove docker images matching %
|
||||
.PHONY: docker-images-rm-%
|
||||
docker-images-rm-%:
|
||||
docker images |awk '$$1 ~ /^$(subst /,\/,$*)/ {print $$3}' |sort -u |while read image; do docker rmi -f $$image; done
|
||||
|
||||
# target docker-login: Exec docker login
|
||||
.PHONY: docker-login
|
||||
docker-login: myos-base
|
||||
$(ECHO) docker login
|
||||
|
||||
# target docker-network-create: Fire docker-network-create-% for DOCKER_NETWORK
|
||||
.PHONY: docker-network-create
|
||||
docker-network-create: docker-network-create-$(DOCKER_NETWORK)
|
||||
|
||||
# target docker-network-create-%: Create docker network %
|
||||
.PHONY: docker-network-create-%
|
||||
docker-network-create-%:
|
||||
[ -n "$(shell docker network ls -q --filter name='^$*$$' 2>/dev/null)" ] \
|
||||
|| { echo -n "Creating docker network $* ... " && $(ECHO) docker network create $* >/dev/null 2>&1 && echo "done" || echo "ERROR"; }
|
||||
|
||||
# target docker-network-rm: Fire docker-network-rm-% for DOCKER_NETWORK
|
||||
.PHONY: docker-network-rm
|
||||
docker-network-rm: docker-network-rm-$(DOCKER_NETWORK)
|
||||
|
||||
# target docker-network-rm-%: Remove docker network %
|
||||
.PHONY: docker-network-rm-%
|
||||
docker-network-rm-%:
|
||||
[ -z "$(shell docker network ls -q --filter name='^$*$$' 2>/dev/null)" ] \
|
||||
|| { echo -n "Removing docker network $* ... " && $(ECHO) docker network rm $* >/dev/null 2>&1 && echo "done" || echo "ERROR"; }
|
||||
|
||||
# target docker-plugin-install: Install docker plugin DOCKER_PLUGIN with DOCKER_PLUGIN_OPTIONS
|
||||
.PHONY: docker-plugin-install
|
||||
docker-plugin-install:
|
||||
$(eval docker_plugin_state := $(shell docker plugin ls | awk '$$2 == "$(DOCKER_PLUGIN)" {print $$NF}') )
|
||||
$(if $(docker_plugin_state),$(if $(filter $(docker_plugin_state),false),echo -n "Enabling docker plugin $(DOCKER_PLUGIN) ... " && $(ECHO) docker plugin enable $(DOCKER_PLUGIN) >/dev/null 2>&1 && echo "done" || echo "ERROR"),echo -n "Installing docker plugin $(DOCKER_PLUGIN) ... " && $(ECHO) docker plugin install $(DOCKER_PLUGIN_OPTIONS) $(DOCKER_PLUGIN) $(DOCKER_PLUGIN_ARGS) >/dev/null 2>&1 && echo "done" || echo "ERROR")
|
||||
|
||||
# target docker-push: Call docker-push for each SERVICES
|
||||
.PHONY: docker-push
|
||||
docker-push:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
@@ -165,6 +195,7 @@ else
|
||||
printf "${COLOR_BROWN}WARNING${COLOR_RESET}: ${COLOR_GREEN}target${COLOR_RESET} $@ ${COLOR_GREEN}not enabled in${COLOR_RESET} $(APP).\n" >&2
|
||||
endif
|
||||
|
||||
# target docker-push-%: Call docker-push with tag % for each SERVICES
|
||||
.PHONY: docker-push-%
|
||||
docker-push-%:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
@@ -176,26 +207,32 @@ else
|
||||
printf "${COLOR_BROWN}WARNING${COLOR_RESET}: ${COLOR_GREEN}target${COLOR_RESET} $@ ${COLOR_GREEN}not enabled in${COLOR_RESET} $(APP).\n" >&2
|
||||
endif
|
||||
|
||||
# target docker-rebuild: Call docker-build target with DOCKER_BUILD_CAHE=false
|
||||
.PHONY: docker-rebuild
|
||||
docker-rebuild:
|
||||
$(call make,docker-build DOCKER_BUILD_CACHE=false)
|
||||
|
||||
# target docker-rebuild-%: Call docker-build-% target with DOCKER_BUILD_CAHE=false
|
||||
.PHONY: docker-rebuild-%
|
||||
docker-rebuild-%:
|
||||
$(call make,docker-build-$* DOCKER_BUILD_CACHE=false)
|
||||
|
||||
# target docker-rm: Fire docker-rm-% for COMPOSE_PROJECT_NAME
|
||||
.PHONY: docker-rm
|
||||
docker-rm: docker-rm-$(COMPOSE_PROJECT_NAME)
|
||||
|
||||
# target docker-rm-%: Remove dockers matching %
|
||||
.PHONY: docker-rm-%
|
||||
docker-rm-%:
|
||||
docker ps -a |awk '$$NF ~ /^$*/ {print $$NF}' |while read docker; do docker rm -f $$docker; done
|
||||
|
||||
# target docker-run: Call docker-run-% target with ARGS for SERVICE
|
||||
.PHONY: docker-run
|
||||
docker-run: SERVICE ?= $(DOCKER_SERVICE)
|
||||
docker-run:
|
||||
$(call make,docker-run-$(SERVICE),,ARGS)
|
||||
|
||||
# target docker-run-%: Call docker-run with image % and command ARGS
|
||||
.PHONY: docker-run-%
|
||||
docker-run-%: docker-build-%
|
||||
$(eval command := $(ARGS))
|
||||
@@ -204,6 +241,7 @@ docker-run-%: docker-build-%
|
||||
$(eval image_id := $(shell docker images -q $(image) 2>/dev/null))
|
||||
$(call docker-run,$(if $(image_id),$(image),$(path)),$(command))
|
||||
|
||||
# target docker-tag: Call docker-tag for each SERVICES
|
||||
.PHONY: docker-tag
|
||||
docker-tag:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
@@ -215,6 +253,7 @@ else
|
||||
printf "${COLOR_BROWN}WARNING${COLOR_RESET}: ${COLOR_GREEN}target${COLOR_RESET} $@ ${COLOR_GREEN}not enabled in${COLOR_RESET} $(APP).\n" >&2
|
||||
endif
|
||||
|
||||
# target docker-tag-%: Call docker-tag with target tag % for each SERVICES
|
||||
.PHONY: docker-tag-%
|
||||
docker-tag-%:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
@@ -226,9 +265,11 @@ else
|
||||
printf "${COLOR_BROWN}WARNING${COLOR_RESET}: ${COLOR_GREEN}target${COLOR_RESET} $@ ${COLOR_GREEN}not enabled in${COLOR_RESET} $(APP).\n" >&2
|
||||
endif
|
||||
|
||||
# target docker-volume-rm: Fire docker-volume-rm-% for COMPOSE_PROJECT_NAME
|
||||
.PHONY: docker-volume-rm
|
||||
docker-volume-rm: docker-volume-rm-$(COMPOSE_PROJECT_NAME)
|
||||
|
||||
# target docker-volume-rm-%: Remove docker volumes matching %
|
||||
.PHONY: docker-volume-rm-%
|
||||
docker-volume-rm-%:
|
||||
docker volume ls |awk '$$2 ~ /^$*/ {print $$2}' |sort -u |while read volume; do docker volume rm $$volume; done
|
||||
|
||||
+8
-5
@@ -1,7 +1,7 @@
|
||||
##
|
||||
# GIT
|
||||
|
||||
# Create branch $(BRANCH) from upstream/$* branch
|
||||
# target git-branch-create-upstream-%: Create git BRANCH from upstream/% branch
|
||||
.PHONY: git-branch-create-upstream-%
|
||||
git-branch-create-upstream-%: myos-base update-upstream
|
||||
$(call exec,git fetch --prune upstream)
|
||||
@@ -9,13 +9,13 @@ git-branch-create-upstream-%: myos-base update-upstream
|
||||
$(call exec,[ $$(git ls-remote --heads upstream $(BRANCH) |wc -l) -eq 0 ] && git push upstream $(BRANCH) || echo Unable to create branch $(BRANCH) on remote upstream.)
|
||||
$(call exec,git checkout $(BRANCH))
|
||||
|
||||
# Delete branch $(BRANCH)
|
||||
# target git-branch-delete: Delete git BRANCH
|
||||
.PHONY: git-branch-delete
|
||||
git-branch-delete: myos-base update-upstream
|
||||
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1 && git branch -d $(BRANCH) || echo Unable to delete branch $(BRANCH).)
|
||||
$(foreach remote,upstream, $(call exec,[ $$(git ls-remote --heads $(remote) $(BRANCH) |wc -l) -eq 1 ] && git push $(remote) :$(BRANCH) || echo Unable to delete branch $(BRANCH) on remote $(remote).) &&) true
|
||||
|
||||
# Merge branch $(BRANCH) into upstream/$* branch
|
||||
# target git-branch-merge-upstream-%: Merge git BRANCH into upstream/% branch
|
||||
.PHONY: git-branch-merge-upstream-%
|
||||
git-branch-merge-upstream-%: myos-base update-upstream
|
||||
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1)
|
||||
@@ -27,19 +27,21 @@ git-branch-merge-upstream-%: myos-base update-upstream
|
||||
$(call exec,git merge --no-ff --no-edit $(BRANCH))
|
||||
$(call exec,git push upstream $*)
|
||||
|
||||
# target git-stash: git stash
|
||||
.PHONY: git-stash
|
||||
git-stash: myos-base git-status
|
||||
if [ ! $(STATUS) -eq 0 ]; then \
|
||||
$(call exec,git stash); \
|
||||
fi
|
||||
|
||||
# target git-status: Define STATUS with number of lines of git status
|
||||
.PHONY: git-status
|
||||
git-status: myos-base
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
$(eval STATUS := $(shell $(call exec,git status -uno --porcelain 2>/dev/null |wc -l)))
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
|
||||
# Create $(TAG) tag to reference upstream/$* branch
|
||||
# target git-tag-create-upstream-%: Create git TAG to reference upstream/% branch
|
||||
.PHONY: git-tag-create-upstream-%
|
||||
git-tag-create-upstream-%: myos-base update-upstream
|
||||
ifneq ($(words $(TAG)),0)
|
||||
@@ -53,7 +55,7 @@ ifneq ($(words $(TAG)),0)
|
||||
$(call exec,git push --tags upstream $*)
|
||||
endif
|
||||
|
||||
# Merge tag $(TAG) into upstream/$* branch
|
||||
# target git-tag-merge-upstream-%: Merge git TAG into upstream/% branch
|
||||
.PHONY: git-tag-merge-upstream-%
|
||||
git-tag-merge-upstream-%: myos-base update-upstream
|
||||
ifneq ($(words $(TAG)),0)
|
||||
@@ -63,6 +65,7 @@ ifneq ($(words $(TAG)),0)
|
||||
$(call exec,git push upstream $*)
|
||||
endif
|
||||
|
||||
# target git-unstash: git stash pop
|
||||
.PHONY: git-unstash
|
||||
git-unstash: myos-base
|
||||
$(eval STATUS ?= 0)
|
||||
|
||||
+13
-3
@@ -1,15 +1,22 @@
|
||||
##
|
||||
# INSTALL
|
||||
|
||||
.PHONY: install app-install
|
||||
install: app-install ## Install application
|
||||
|
||||
# target install-mysql-database-%: Import %.mysql.gz to database %
|
||||
# on local host
|
||||
## it creates database %
|
||||
## it creates user % with password % and all privileges on database %
|
||||
## it imports %.mysql.gz file in database %
|
||||
.PHONY: install-mysql-database-%
|
||||
install-mysql-database-%: myos-base
|
||||
$(call exec,mysql -h mysql -u root -proot $* -e "use $*" >/dev/null 2>&1 || mysql -h mysql -u root -proot mysql -e "create database $* character set utf8 collate utf8_unicode_ci;")
|
||||
$(call exec,mysql -h mysql -u $* -p$* $* -e "use $*" >/dev/null 2>&1 || mysql -h mysql -u root -proot mysql -e "grant all privileges on $*.* to '\''$*'\''@'\''%'\'' identified by '\''$*'\''; flush privileges;")
|
||||
$(call exec,[ $$(mysql -h mysql -u $* -p$* $* -e "show tables" 2>/dev/null |wc -l) -eq 0 ] && [ -f "${APP_DIR}/$*.mysql.gz" ] && gzip -cd "${APP_DIR}/$*.mysql.gz" |mysql -h mysql -u root -proot $* || true)
|
||||
|
||||
# target install-pgsql-database-%: Import %.pgsql.gz to database %
|
||||
# on local host
|
||||
## it creates database %
|
||||
## it creates user % with password % and all privileges on database %
|
||||
## it imports %.pgsql.gz file in database %
|
||||
.PHONY: install-pgsql-database-%
|
||||
install-pgsql-database-%: myos-base
|
||||
$(call exec,PGPASSWORD=$* psql -h postgres -U $* template1 -c "\q" >/dev/null 2>&1 || PGPASSWORD=postgres psql -h postgres -U postgres -c "create user $* with createdb password '\''$*'\'';")
|
||||
@@ -17,14 +24,17 @@ install-pgsql-database-%: myos-base
|
||||
$(call exec,[ $$(PGPASSWORD=$* psql -h postgres -U $* -d $* -c "\d" 2>/dev/null |wc -l) -eq 0 ] && [ -f "${APP_DIR}/$*.pgsql.gz" ] && gzip -cd "${APP_DIR}/$*.pgsql.gz" |PGPASSWORD="postgres" psql -h postgres -U postgres -d $* || true)
|
||||
$(call exec,[ $$(PGPASSWORD=$* psql -h postgres -U $* -d $* -c "\d" 2>/dev/null |wc -l) -eq 0 ] && [ -f "${APP_DIR}/$*.pgsql" ] && PGPASSWORD="postgres" psql -h postgres -U postgres -c "ALTER ROLE $* WITH SUPERUSER" && PGPASSWORD="postgres" pg_restore -h postgres --no-owner --role=$* -U postgres -d $* ${APP_DIR}/$*.pgsql && PGPASSWORD="postgres" psql -h postgres -U postgres -c "ALTER ROLE $* WITH NOSUPERUSER" || true)
|
||||
|
||||
# target install-build-parameters: Call install-parameters with file * and dest build
|
||||
.PHONY: install-build-parameters
|
||||
install-build-parameters:
|
||||
$(call install-parameters,,*,build)
|
||||
|
||||
# target install-parameters: Call install-parameters
|
||||
.PHONY: install-parameters
|
||||
install-parameters:
|
||||
$(call install-parameters)
|
||||
|
||||
# target install-parameters-%: Call install-parameters with app %
|
||||
.PHONY: install-parameters-%
|
||||
install-parameters-%:
|
||||
$(call install-parameters,$*)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
##
|
||||
# CLEAN
|
||||
|
||||
.PHONY: clean-js-app
|
||||
clean-js-app: clean-js-assets-deps
|
||||
|
||||
.PHONY: clean-js-assets-deps
|
||||
clean-js-assets-deps: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),rm -Rf node_modules/*)
|
||||
@@ -1,21 +0,0 @@
|
||||
##
|
||||
# DEV
|
||||
|
||||
## Build assets
|
||||
.PHONY: dev-assets
|
||||
dev-assets: ## Build assets
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn build:dev:watch)
|
||||
|
||||
.PHONY: dev-outdated
|
||||
dev-outdated:
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn outdated)
|
||||
|
||||
# compile webpack assets (REACT)
|
||||
.PHONY: dev-webpack-compile
|
||||
dev-webpack-compile: bootstrap ## Compile dev assets
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn encore dev)
|
||||
|
||||
# watch webpack assets updates (REACT)
|
||||
.PHONY: dev-webpack-watch
|
||||
dev-webpack-watch: bootstrap ## Watch dev assets update
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn encore dev --watch)
|
||||
@@ -1,22 +0,0 @@
|
||||
##
|
||||
# INSTALL
|
||||
|
||||
.PHONY: install-bower
|
||||
install-bower: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),npm install bower --allow-root)
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),./node_modules/bower/bin/bower install --allow-root)
|
||||
|
||||
.PHONY: install-npm
|
||||
install-npm: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),npm install)
|
||||
|
||||
.PHONY: install-npm-run-build
|
||||
install-npm-run-build: install-npm-run-build-$(SYMFONY_ENV)
|
||||
|
||||
.PHONY: install-npm-run-build-%
|
||||
install-npm-run-build-%: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),npm run build:$*)
|
||||
|
||||
.PHONY: install-yarn
|
||||
install-yarn: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn install)
|
||||
@@ -1,17 +0,0 @@
|
||||
##
|
||||
# TEST
|
||||
|
||||
.PHONY: test-assets
|
||||
test-assets: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn test)
|
||||
|
||||
## Run functional tests (make test-func TEST="S01-U1-find-product")
|
||||
.PHONY: test-func-js
|
||||
test-func-js: bootstrap ## Run functional tests (js)
|
||||
ifdef TEST
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn test:func -- --test tests/Functional/specs/$(TEST).js --env $(TESTENV))
|
||||
else ifdef TESTSUITE
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn test:func -- --tag $(TESTSUITE) --env $(TESTENV))
|
||||
else
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),yarn test:func -- --env $(TESTENV))
|
||||
endif
|
||||
@@ -1,6 +0,0 @@
|
||||
##
|
||||
# UPDATE
|
||||
|
||||
.PHONY: update-npm
|
||||
update-npm: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),npm upgrade)
|
||||
@@ -7,6 +7,7 @@ SSH_PUBLIC_HOST_KEYS ?= $(SSH_REMOTE_HOSTS) $(SSH_BASTION_HOSTNAME)
|
||||
SSH_PRIVATE_IP_RANGE ?= 10.10.*
|
||||
SSH_REMOTE_HOSTS ?= github.com gitlab.com
|
||||
|
||||
# function ssh-connect: Exec command on remote hosts with tty
|
||||
define ssh-connect
|
||||
$(eval hosts := $(1))
|
||||
$(eval command := $(2))
|
||||
@@ -15,6 +16,7 @@ define ssh-connect
|
||||
$(foreach host,$(hosts),$(call exec,ssh -t -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $(user)@$(host) "$(command)") ||) true
|
||||
endef
|
||||
|
||||
# function ssh-exec: Exec command on remote hosts without tty
|
||||
define ssh-exec
|
||||
$(eval hosts := $(1))
|
||||
$(eval command := $(2))
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
##
|
||||
# SSH
|
||||
|
||||
# target ssh: Call ssh-connect with command SHELL
|
||||
.PHONY: ssh
|
||||
ssh: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME)
|
||||
ssh: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME) ## Connect to first remote host
|
||||
$(call ssh-connect,$(AWS_INSTANCE_IP),$(SHELL))
|
||||
|
||||
# target ssh-connect: Call ssh-connect with command make connect
|
||||
.PHONY: ssh-connect
|
||||
ssh-connect: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME)
|
||||
$(call ssh-connect,$(AWS_INSTANCE_IP),make connect $(if $(SERVICE),SERVICE=$(SERVICE)))
|
||||
|
||||
# target ssh-connect: Call ssh-connect with command make exec
|
||||
.PHONY: ssh-exec
|
||||
ssh-exec: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME)
|
||||
$(call ssh-exec,$(AWS_INSTANCE_IP),make exec $(if $(SERVICE),SERVICE=$(SERVICE)) $(if $(ARGS),ARGS='\''"$(ARGS)"'\''))
|
||||
|
||||
# target ssh-run: Call ssh-connect with command make run
|
||||
.PHONY: ssh-run
|
||||
ssh-run: aws-ec2-get-PrivateIpAddress-$(SERVER_NAME)
|
||||
$(call ssh-exec,$(AWS_INSTANCE_IP),make run $(if $(SERVICE),SERVICE=$(SERVICE)) $(if $(ARGS),ARGS='\''"$(ARGS)"'\''))
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
##
|
||||
# CACHE
|
||||
|
||||
## Clear symfony cache
|
||||
.PHONY: cache-clear
|
||||
cache-clear: cache-clear-$(SYMFONY_ENV)
|
||||
|
||||
.PHONY: cache-clear-%
|
||||
cache-clear-%: bootstrap ## Clear symfony cache
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),app/console cache:clear --env=$*)
|
||||
|
||||
.PHONY: cache-warmup
|
||||
cache-warmup: cache-warmup-$(SYMFONY_ENV)
|
||||
|
||||
.PHONY: cache-warmup-%
|
||||
cache-warmup-%: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),app/console cache:warmup --env=$*)
|
||||
@@ -1,11 +0,0 @@
|
||||
##
|
||||
# CLEAN
|
||||
|
||||
.PHONY: app-symfony-clean
|
||||
app-symfony-clean: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),rm -rf app/bootstrap.php.cache)
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),rm -rf app/cache/* app/cach~)
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),rm -rf app/logs/*)
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),rm -rf var/cache/* var/cach~)
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),rm -rf var/logs/*)
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),rm -rf vendor/*)
|
||||
@@ -1,24 +0,0 @@
|
||||
COMPOSER_ARGS ?= --optimize-autoloader
|
||||
COMPOSER_MEMORY_LIMIT ?= -1
|
||||
CONTEXT += COMPOSER_ARGS
|
||||
|
||||
ifeq ($(SYMFONY_ENV), prod)
|
||||
COMPOSER_ARGS += --classmap-authoritative --prefer-dist --no-dev --no-interaction
|
||||
endif
|
||||
ifeq ($(DRONE), true)
|
||||
COMPOSER_ARGS += --no-progress
|
||||
endif
|
||||
|
||||
define composer
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),COMPOSER_MEMORY_LIMIT=$(COMPOSER_MEMORY_LIMIT) SYMFONY_ENV=$(SYMFONY_ENV) composer $(1) $(COMPOSER_ARGS))
|
||||
endef
|
||||
|
||||
define composer-require-vendor-binary
|
||||
$(eval vendor:=$(1))
|
||||
$(eval binary:=$(or $(2),$(lastword $(subst /, ,$(vendor)))))
|
||||
$(eval version:=$(or $(addprefix :,$(3)),$(shell awk '/'$(subst /,\\/,$(vendor))'/ {gsub("[\",]","",$$2); print ":"$$2}' composer.json 2>/dev/null)))
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
$(eval COMPOSER_REQUIRE := $(shell $(call docker-compose-exec,$(DOCKER_SERVICE),[ -f vendor/$(vendor)/$(binary) ] || echo true)))
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
$(if $(COMPOSER_REQUIRE),$(call docker-compose-exec,$(DOCKER_SERVICE),mkdir -p vendor/$(vendor) && cd /tmp && COMPOSER_MEMORY_LIMIT=$(COMPOSER_MEMORY_LIMIT) SYMFONY_ENV=$(SYMFONY_ENV) composer require "$(vendor)$(version)" --prefer-source --no-interaction --dev && cd - && ln -s /tmp/vendor/$(vendor)/$(binary) vendor/$(vendor)/$(binary)))
|
||||
endef
|
||||
@@ -1,7 +0,0 @@
|
||||
BUILD_ENV_VARS += SYMFONY_ENV
|
||||
|
||||
ifneq (,$(filter $(ENV),$(ENV_DEPLOY)))
|
||||
SYMFONY_ENV ?= prod
|
||||
else
|
||||
SYMFONY_ENV ?= dev
|
||||
endif
|
||||
@@ -1,10 +0,0 @@
|
||||
##
|
||||
# DEV
|
||||
|
||||
.PHONY: dev-phpcs
|
||||
dev-phpcs: bootstrap install-phpcs
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/phpcs --standard=PSR2 --colors -p ./src)
|
||||
|
||||
.PHONY: dev-phpcbf
|
||||
dev-phpcbf: bootstrap install-phpcbf
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/phpcbf ./src/ --ignore=*.js)
|
||||
@@ -1,42 +0,0 @@
|
||||
##
|
||||
# INSTALL
|
||||
|
||||
.PHONY: install-assets
|
||||
install-assets: install-assets-$(SYMFONY_ENV)
|
||||
|
||||
.PHONY: install-assets-%
|
||||
install-assets-%: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),app/console assetic:dump --env=$*)
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),app/console assets:install --env=$*)
|
||||
|
||||
.PHONY: install-codecept
|
||||
install-codecept: bootstrap install-phpunit vendor/codeception/codeception/codecept
|
||||
|
||||
vendor/codeception/codeception/codecept:
|
||||
$(call composer-require-vendor-binary,codeception/codeception,codecept)
|
||||
|
||||
.PHONY: install-composer
|
||||
install-composer: bootstrap
|
||||
$(call composer,install)
|
||||
|
||||
.PHONY: install-doctrine-schema-update
|
||||
install-doctrine-schema-update: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),php app/console doctrine:schema:update --force)
|
||||
|
||||
.PHONY: install-phpcbf
|
||||
install-phpcbf: bootstrap vendor/squizlabs/php_codesniffer/bin/phpcbf
|
||||
|
||||
vendor/squizlabs/php_codesniffer/bin/phpcbf:
|
||||
$(call composer-require-vendor-binary,squizlabs/php_codesniffer,bin/phpcbf)
|
||||
|
||||
.PHONY: install-phpcs
|
||||
install-phpcs: bootstrap vendor/squizlabs/php_codesniffer/bin/phpcs
|
||||
|
||||
vendor/squizlabs/php_codesniffer/bin/phpcs:
|
||||
$(call composer-require-vendor-binary,squizlabs/php_codesniffer,bin/phpcs)
|
||||
|
||||
.PHONY: install-phpunit
|
||||
install-phpunit: bootstrap vendor/phpunit/phpunit/phpunit
|
||||
|
||||
vendor/phpunit/phpunit/phpunit:
|
||||
$(call composer-require-vendor-binary,phpunit/phpunit)
|
||||
@@ -1,44 +0,0 @@
|
||||
##
|
||||
# TEST
|
||||
|
||||
## Run unit tests
|
||||
.PHONY: test
|
||||
test: test-unit ## Run unit tests
|
||||
|
||||
## Run codeception tests
|
||||
.PHONY: test-codeception-%
|
||||
test-codeception-%: bootstrap install-codecept ## Run codeception tests
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/codecept run $*)
|
||||
|
||||
## Run old unit tests with code coverage
|
||||
.PHONY: test-coverage
|
||||
test-coverage: bootstrap install-phpunit ## Run code coverage
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/phpunit --testsuite unit --coverage-text)
|
||||
|
||||
## Run codeception tests with coverage
|
||||
.PHONY: test-coverage-codeception-%
|
||||
test-coverage-codeception-%: bootstrap install-codecept ## Run codeception tests with coverage
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/codecept run $* --coverage --coverage-html)
|
||||
|
||||
## Run phpunit functional tests
|
||||
.PHONY: test-func
|
||||
test-func: bootstrap install-phpunit ## Run functional tests
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/phpunit --testsuite functional)
|
||||
|
||||
## Run search tests
|
||||
.PHONY: test-search
|
||||
test-search: bootstrap install-phpunit ## Run search tests
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/phpunit --testsuite search)
|
||||
|
||||
.PHONY: test-templates
|
||||
test-templates: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),php app/console lint:twig @UIBundle)
|
||||
|
||||
## Run old unit tests
|
||||
.PHONY: test-unit
|
||||
test-unit: bootstrap install-phpunit ## Run unit tests
|
||||
ifdef FILTER
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/phpunit --testsuite unit --filter $(FILTER))
|
||||
else
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),bin/phpunit --testsuite unit)
|
||||
endif
|
||||
@@ -1,6 +0,0 @@
|
||||
##
|
||||
# UPDATE
|
||||
|
||||
.PHONY: update-database
|
||||
update-database: bootstrap
|
||||
$(call docker-compose-exec,$(DOCKER_SERVICE),app/console --no-interaction doctrine:migration:migrate)
|
||||
@@ -0,0 +1,46 @@
|
||||
##
|
||||
# RELEASE
|
||||
|
||||
# target release-check: Define RELEASE_BRANCH and RELEASE_VERSION
|
||||
.PHONY: release-check
|
||||
release-check:
|
||||
ifneq ($(words $(ARGS)),0)
|
||||
$(eval RELEASE_VERSION := $(word 1, $(ARGS)))
|
||||
$(eval RELEASE_BRANCH := release/$(RELEASE_VERSION))
|
||||
else
|
||||
ifneq ($(findstring $(firstword $(subst /, ,$(BRANCH))),release),)
|
||||
$(eval RELEASE_BRANCH := $(BRANCH))
|
||||
$(eval RELEASE_VERSION := $(word 2, $(subst /, ,$(BRANCH))))
|
||||
endif
|
||||
endif
|
||||
$(if $(filter VERSION=%,$(MAKEFLAGS)), $(eval RELEASE_VERSION:=$(VERSION)) $(eval RELEASE_BRANCH := release/$(RELEASE_VERSION)))
|
||||
$(if $(findstring $(firstword $(subst /, ,$(RELEASE_BRANCH))),release),,$(error Please provide a VERSION or a release BRANCH))
|
||||
|
||||
# target release-create: Create release VERSION from upstream/wip branch
|
||||
.PHONY: release-create
|
||||
release-create: release-check git-stash
|
||||
$(call make,git-branch-create-upstream-wip BRANCH=$(RELEASE_BRANCH))
|
||||
$(call make,git-unstash,,STATUS)
|
||||
|
||||
# target release-finish: Merge release VERSION in master branch
|
||||
.PHONY: release-finish
|
||||
release-finish: release-check git-stash
|
||||
$(call make,git-branch-merge-upstream-master BRANCH=$(RELEASE_BRANCH))
|
||||
$(call make,git-tag-create-upstream-master TAG=$(RELEASE_VERSION))
|
||||
$(call make,git-tag-merge-upstream-wip TAG=$(RELEASE_VERSION))
|
||||
$(call make,git-branch-delete BRANCH=$(RELEASE_BRANCH))
|
||||
$(call make,git-unstash,,STATUS)
|
||||
|
||||
# target release-update: Update RELEASE with RELEASE_VERSION in .env
|
||||
.PHONY: release-update
|
||||
release-update:
|
||||
$(ECHO) awk -v s=RELEASE=$(RELEASE_VERSION) '/^RELEASE=/{$$0=s;f=1} {a[++n]=$$0} END{if(!f)a[++n]=s;for(i=1;i<=n;i++)print a[i]>ARGV[1]}' .env
|
||||
|
||||
# target release-upgrade: Run migration targets to upgrade specific releases
|
||||
.PHONY: release-upgrade
|
||||
release-upgrade: $(patsubst %,release-upgrade-from-%,$(RELEASE_UPGRADE)) release-update ## Upgrade release
|
||||
|
||||
# target release-upgrade-from-%: Sample of catch-all release migration target
|
||||
.PHONY: release-upgrade-from-%
|
||||
release-upgrade-from-%:
|
||||
echo "Upgrading from release: $*"
|
||||
@@ -1,17 +1,21 @@
|
||||
##
|
||||
# SUBREPO
|
||||
|
||||
# target subrepo-branch-delete subrepo-branch-deletes: Call subrepo-branch-delete target in folder ..
|
||||
.PHONY: subrepo-branch-delete subrepos-branch-delete
|
||||
subrepo-branch-delete subrepos-branch-delete:
|
||||
$(call make,subrepo-branch-delete,..,SUBREPO BRANCH)
|
||||
|
||||
# target subrepo-push subrepos-push: Call subrepo-push target in folder ..
|
||||
.PHONY: subrepo-push subrepos-push
|
||||
subrepo-push subrepos-push:
|
||||
$(call make,subrepo-push,..,SUBREPO BRANCH)
|
||||
|
||||
# target subrepo-tag-create-% subrepos-tag-create-%: Call subrepo-tag-create-% target in folder ..
|
||||
.PHONY: subrepo-tag-create-% subrepos-tag-create-%
|
||||
subrepo-tag-create-% subrepos-tag-create-%:
|
||||
$(call make,subrepo-tag-create-$*,..,SUBREPO TAG)
|
||||
|
||||
# target subrepo-update subrepos-update: Fire bootstrap-git git-stash subrepo-push git-unstash
|
||||
.PHONY: subrepo-update subrepos-update
|
||||
subrepo-update subrepos-update: bootstrap-git git-stash subrepo-push git-unstash
|
||||
|
||||
Reference in New Issue
Block a user