wip
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ bootstrap: bootstrap-git bootstrap-docker app-bootstrap ## Update application fi
|
||||
# target bootstrap-docker: Build and start application dockers
|
||||
# on local host
|
||||
.PHONY: boostrap-docker
|
||||
bootstrap-docker: install-bin-docker docker-network-create
|
||||
bootstrap-docker: install-bin-docker setup-docker-group
|
||||
|
||||
# target bootstrap-git: Fire update-app
|
||||
.PHONY: bootstrap-git
|
||||
@@ -215,4 +215,4 @@ upgrade: update app-upgrade release-upgrade ## Upgrade application
|
||||
|
||||
# target %-rule-exists: Print a warning message if % target does not exists
|
||||
%-rule-exists:
|
||||
$(if $(filter $*,$(MAKECMDGOALS)),$(if $(filter-out $*,$(MAKE_TARGETS)),$(call WARNING,no target,$*,$(APP))))
|
||||
$(if $(filter $*,$(MAKECMDGOALS)),$(if $(filter-out $*,$(MAKE_TARGETS)),$(call WARNING,target,$*,unavailable in app,$(APP))))
|
||||
|
||||
@@ -27,7 +27,6 @@ DOCKER_BUILD_TARGETS ?= $(ENV_DEPLOY)
|
||||
DOCKER_BUILD_VARS ?= APP BRANCH DOCKER_GID DOCKER_REPOSITORY GID GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME SSH_BASTION_HOSTNAME SSH_BASTION_USERNAME SSH_PRIVATE_IP_RANGE SSH_PUBLIC_HOST_KEYS SSH_REMOTE_HOSTS UID USER VERSION
|
||||
DOCKER_COMPOSE_DOWN_OPTIONS ?=
|
||||
DOCKER_COMPOSE_UP_OPTIONS ?= -d
|
||||
DOCKER_GID ?= $(call gid,docker)
|
||||
DOCKER_IMAGE_TAG ?= $(if $(filter $(ENV),$(ENV_DEPLOY)),$(VERSION),$(if $(DRONE_BUILD_NUMBER),$(DRONE_BUILD_NUMBER),latest))
|
||||
DOCKER_IMAGES ?= $(patsubst %/,%,$(patsubst docker/%,%,$(dir $(wildcard docker/*/Dockerfile))))
|
||||
DOCKER_PLUGIN ?= rexray/s3fs:latest
|
||||
@@ -45,7 +44,7 @@ DOCKER_REPOSITORY ?= $(subst _,/,$(COMPOSE_PROJECT_NAME))
|
||||
DOCKER_SERVICE ?= $(lastword $(DOCKER_SERVICES))
|
||||
DOCKER_SERVICES ?= $(eval IGNORE_DRYRUN := true)$(shell $(call docker-compose,--log-level critical config --services))$(eval IGNORE_DRYRUN := false)
|
||||
DOCKER_SHELL ?= $(SHELL)
|
||||
ENV_VARS += COMPOSE_PROJECT_NAME COMPOSE_SERVICE_NAME DOCKER_BUILD_TARGET DOCKER_GID DOCKER_IMAGE_TAG DOCKER_REGISTRY DOCKER_REPOSITORY DOCKER_SHELL
|
||||
ENV_VARS += COMPOSE_PROJECT_NAME COMPOSE_SERVICE_NAME DOCKER_BUILD_TARGET DOCKER_IMAGE_TAG DOCKER_REGISTRY DOCKER_REPOSITORY DOCKER_SHELL
|
||||
|
||||
ifneq ($(DOCKER_RUN),)
|
||||
DOCKER_COMPOSE ?= docker/compose:$(COMPOSE_VERSION)
|
||||
@@ -61,7 +60,7 @@ DOCKER_COMPOSE_UP_OPTIONS := -d --build
|
||||
endif
|
||||
|
||||
# https://github.com/docker/libnetwork/pull/2348
|
||||
ifeq ($(HOST_SYSTEM), DARWIN)
|
||||
ifeq ($(OPERATING_SYSTEM),Darwin)
|
||||
DOCKER_HOST_IFACE ?= $(shell docker run --rm -it --net=host alpine /sbin/ip -4 route list match 0/0 2>/dev/null |awk '{print $$5}' |awk '!seen[$$0]++' |head -1)
|
||||
DOCKER_HOST_INET ?= $(shell docker run --rm -it --net=host alpine /sbin/ip -4 addr show $(DOCKER_HOST_IFACE) 2>/dev/null |awk '$$1 == "inet" {sub(/\/.*/,"",$$2); print $$2}')
|
||||
DOCKER_INTERNAL_DOCKER_GATEWAY ?= $(shell docker run --rm -it alpine getent hosts gateway.docker.internal |awk '{print $$1}' |head -1)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
SETUP_NFSD ?= false
|
||||
SETUP_NFSD_OSX_CONFIG ?= nfs.server.bonjour=0 nfs.server.mount.regular_files=1 nfs.server.mount.require_resv_port=0 nfs.server.nfsd_threads=16 nfs.server.async=1
|
||||
SETUP_SYSCTL ?= false
|
||||
SETUP_SYSCTL_CONFIG ?= vm.max_map_count=262144 vm.overcommit_memory=1 fs.file-max=8388608 net.core.somaxconn=1024
|
||||
+4
-4
@@ -168,7 +168,7 @@ docker-push:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-push,$(service)))
|
||||
else
|
||||
$(call WARNING,disabled target,$@,$(APP))
|
||||
$(call WARNING,target,$@,disabled in app,$(APP))
|
||||
endif
|
||||
|
||||
# target docker-push-%: Call docker-push with tag % for each SERVICES
|
||||
@@ -177,7 +177,7 @@ docker-push-%:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-push,$(service),,$*))
|
||||
else
|
||||
$(call WARNING,disabled target,$@,$(APP))
|
||||
$(call WARNING,target,$@,disabled in app,$(APP))
|
||||
endif
|
||||
|
||||
# target docker-rebuild: Call docker-build target with DOCKER_BUILD_CAHE=false
|
||||
@@ -220,7 +220,7 @@ docker-tag:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-tag,$(service)))
|
||||
else
|
||||
$(call WARNING,disabled target,$@,$(APP))
|
||||
$(call WARNING,target,$@,disabled in app,$(APP))
|
||||
endif
|
||||
|
||||
# target docker-tag-%: Call docker-tag with target tag % for each SERVICES
|
||||
@@ -229,7 +229,7 @@ docker-tag-%:
|
||||
ifneq ($(filter $(DEPLOY),true),)
|
||||
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-tag,$(service),,,,$*))
|
||||
else
|
||||
$(call WARNING,disabled target,$@,$(APP))
|
||||
$(call WARNING,target,$@,disabled in app,$(APP))
|
||||
endif
|
||||
|
||||
# target docker-volume-rm: Fire docker-volume-rm-% for COMPOSE_PROJECT_NAME
|
||||
|
||||
+15
-15
@@ -1,6 +1,21 @@
|
||||
##
|
||||
# INSTALL
|
||||
|
||||
# target install-build-config: Call install-config with file * and dest build
|
||||
.PHONY: install-build-config
|
||||
install-build-config:
|
||||
$(call install-config,,*,build)
|
||||
|
||||
# target install-config: Call install-config
|
||||
.PHONY: install-config
|
||||
install-config:
|
||||
$(call install-config)
|
||||
|
||||
# target install-config-%: Call install-config with app %
|
||||
.PHONY: install-config-%
|
||||
install-config-%:
|
||||
$(call install-config,$*)
|
||||
|
||||
# target install-mysql-database-%: Import %.mysql.gz to database %
|
||||
# on local host
|
||||
## it creates database %
|
||||
@@ -33,18 +48,3 @@ 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" ]) \
|
||||
&& $(call exec,$(RUN) sh -c '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"') \
|
||||
||:
|
||||
|
||||
# target install-build-config: Call install-config with file * and dest build
|
||||
.PHONY: install-build-config
|
||||
install-build-config:
|
||||
$(call install-config,,*,build)
|
||||
|
||||
# target install-config: Call install-config
|
||||
.PHONY: install-config
|
||||
install-config:
|
||||
$(call install-config)
|
||||
|
||||
# target install-config-%: Call install-config with app %
|
||||
.PHONY: install-config-%
|
||||
install-config-%:
|
||||
$(call install-config,$*)
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
##
|
||||
# SETUP
|
||||
|
||||
.PHONY: setup-sysctl
|
||||
setup-sysctl:
|
||||
ifeq ($(SETUP_SYSCTL),true)
|
||||
$(foreach config,$(SETUP_SYSCTL_CONFIG),$(call docker-run,sysctl -q -w $(config),--privileged alpine) &&) true
|
||||
endif
|
||||
|
||||
.PHONY: setup-nfsd
|
||||
setup-nfsd:
|
||||
ifeq ($(SETUP_NFSD),true)
|
||||
ifeq ($(HOST_SYSTEM),DARWIN)
|
||||
$(call setup-nfsd-osx)
|
||||
endif
|
||||
endif
|
||||
SETUP_NFSD ?= false
|
||||
SETUP_NFSD_OSX_CONFIG ?= nfs.server.bonjour=0 nfs.server.mount.regular_files=1 nfs.server.mount.require_resv_port=0 nfs.server.nfsd_threads=16 nfs.server.async=1
|
||||
SETUP_SYSCTL ?= false
|
||||
SETUP_SYSCTL_CONFIG ?= vm.max_map_count=262144 vm.overcommit_memory=1 fs.file-max=8388608 net.core.somaxconn=1024
|
||||
|
||||
define setup-nfsd-osx
|
||||
$(call INFO,setup-nfsd-osx,$(1)$(comma) $(2)$(comma) $(3))
|
||||
@@ -0,0 +1,31 @@
|
||||
##
|
||||
# SETUP
|
||||
|
||||
# target setup-docker-group: Call ansible to add user in docker group if needed
|
||||
.PHONY: setup-docker-group
|
||||
setup-docker-group:
|
||||
ifneq ($(DOCKER),)
|
||||
ifeq ($(or $(filter $(USER),$(subst $(comma), ,$(shell awk -F':' '$$1 == "docker" {print $$4}' /etc/group))),$(filter 0,$(UID))),)
|
||||
$(call ansible-user-add-groups,$(USER),docker)
|
||||
$(call WARNING,user,$(USER),added in group,docker)
|
||||
endif
|
||||
ifeq ($(filter 0 $(DOCKER_GID),$(shell id -G)),)
|
||||
$(call ERROR,YOU MUST LOGOUT NOW AND LOGIN BACK TO GET DOCKER GROUP MEMBERSHIP)
|
||||
endif
|
||||
endif
|
||||
|
||||
# target setup-nfsd: Call setup-nfsd-osx if SETUP_NFSD=true and OPERATING_SYSTEM=Darwin
|
||||
.PHONY: setup-nfsd
|
||||
setup-nfsd:
|
||||
ifeq ($(SETUP_NFSD),true)
|
||||
ifeq ($(OPERATING_SYSTEM),Darwin)
|
||||
$(call setup-nfsd-osx)
|
||||
endif
|
||||
endif
|
||||
|
||||
# target setup-sysctl: Add sysctl config for each SETUP_SYSCTL_CONFIG
|
||||
.PHONY: setup-sysctl
|
||||
setup-sysctl:
|
||||
ifeq ($(SETUP_SYSCTL),true)
|
||||
$(foreach config,$(SETUP_SYSCTL_CONFIG),$(call docker-run,sysctl -q -w $(config),--privileged alpine) &&) true
|
||||
endif
|
||||
Reference in New Issue
Block a user