From cfc7d1ca0ba9126dfb9867b19ede515307237592 Mon Sep 17 00:00:00 2001 From: Andreas Neue Date: Thu, 29 Sep 2022 10:25:43 +0200 Subject: [PATCH] deploy type copy --- Makefile | 15 ++++++++++++--- README.md | 27 +++++++++++++++++++++++---- copy.mk | 10 ++++++++++ docker.mk | 20 -------------------- 4 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 copy.mk diff --git a/Makefile b/Makefile index c952de0..3620908 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ .PHONY: self-update create-contexts deploy upload pull start stop restart +include make-deploy/copy.mk include make-deploy/docker.mk include make-deploy/k8s.mk include make-deploy/cron.mk @@ -12,9 +13,17 @@ self-update: deploy: upload pre-deploy pull start post-deploy -pre-deploy: pre-deploy-$(DEPLOY_TYPE) - -post-deploy: post-deploy-$(DEPLOY_TYPE) +pre-deploy: + @- echo "\n### running pre-deploy script" + @- $(foreach host,$(DEPLOY_HOSTS), \ + ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy.sh"; \ + ) + +post-deploy: + @- echo "\n### running post-deploy script" + @- $(foreach host,$(DEPLOY_HOSTS), \ + ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy.sh"; \ + ) upload: @- echo "\n### uploading files" diff --git a/README.md b/README.md index 188a4cd..d251e36 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,6 @@ Example `secrets.mk`: ## Usage -### Available options for DEPLOY_TYPE - -compose, swarm, k8s (TBD), helm (TBD), cron (TBD) - ### Start the deployment process make deploy @@ -46,3 +42,26 @@ compose, swarm, k8s (TBD), helm (TBD), cron (TBD) make create-docker-contexts +### Update make-deploy submodule in your project + + make self-update + +### Available options for DEPLOY_TYPE + +copy, compose, swarm, k8s (TBD), helm (TBD), cron (TBD) + +#### copy + +Just copy the repo to the remote location(s). Put additional logic into pre- and post-deploy.sh. + +#### compose + +Docker Compose deployment. + +##### swarm + +Docker Swarm deployment. + +##### k8s, helm, cron + +To be implemented. diff --git a/copy.mk b/copy.mk new file mode 100644 index 0000000..fb1234f --- /dev/null +++ b/copy.mk @@ -0,0 +1,10 @@ +# copy +# +# this just rsyncs the stuff to the remote server(s) and runs +# pre- and post-deploy + +pull-copy: + # nop + +start-copy: + # nop diff --git a/docker.mk b/docker.mk index 8bb0e5e..41d269a 100644 --- a/docker.mk +++ b/docker.mk @@ -8,26 +8,6 @@ create-docker-contexts: docker context create $(host) --description "$(host)" --docker "host=ssh://$(SSH_USER)@$(host)"; \ ) -pre-deploy-compose: pre-deploy-docker - -post-deploy-compose: post-deploy-docker - -pre-deploy-swarm: pre-deploy-docker - -post-deploy-swarm: post-deploy-docker - -pre-deploy-docker: - @- echo "\n### running pre-deploy script" - @- $(foreach host,$(DEPLOY_HOSTS), \ - ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy.sh"; \ - ) - -post-deploy-docker: - @- echo "\n### running post-deploy script" - @- $(foreach host,$(DEPLOY_HOSTS), \ - ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy.sh"; \ - ) - pull-compose: @- echo "\n### pulling image(s)" @- $(foreach ctx,$(DEPLOY_HOSTS), \