-
-
Save JackMoth/abeed8614579cf766be6130443a5994d to your computer and use it in GitHub Desktop.
Revisions
-
mpneuried revised this gist
Dec 18, 2017 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -76,7 +76,7 @@ endif ifdef AWS_CLI_REGION CMD_REPOLOGIN += " --region $(AWS_CLI_REGION)" endif CMD_REPOLOGIN += " get-login --no-include-email \)" # login to AWS-ECR repo-login: ## Auto login to AWS-ECR unsing aws-cli This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -93,10 +93,10 @@ endif ifdef AWS_CLI_REGION CMD_REPOLOGIN += "--region $(AWS_CLI_REGION)" endif CMD_REPOLOGIN += "get-login --no-include-email" repo-login: ## Auto login to AWS-ECR unsing aws-cli @eval $(CMD_REPOLOGIN) version: ## output to version @echo $(VERSION) -
mpneuried revised this gist
Oct 9, 2017 . 2 changed files with 19 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,14 @@ # import config. # You can change the default config with `make cnf="config_special.env" build` cnf ?= config.env include $(cnf) export $(shell sed 's/=.*//' $(cnf)) # import deploy config # You can change the default deploy config with `make cnf="deploy_special.env" release` dpl ?= deploy.env include $(dpl) export $(shell sed 's/=.*//' $(dpl)) # grep the version from the mix file VERSION=$(shell ./version.sh) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,16 @@ ### THIS IST THE VERSION WITH docker-compose # import config. # You can change the default config with `make cnf="config_special.env" build` cnf ?= config.env include $(cnf) export $(shell sed 's/=.*//' $(cnf)) # import deploy config # You can change the default deploy config with `make cnf="deploy_special.env" release` dpl ?= deploy.env include $(dpl) export $(shell sed 's/=.*//' $(dpl)) # grep the version from the mix file VERSION=$(shell ./version.sh) -
mpneuried revised this gist
Oct 9, 2017 . 2 changed files with 67 additions and 66 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,47 +17,56 @@ export $(shell sed 's/=.*//' $(deployfile)) # grep the version from the mix file VERSION=$(shell ./version.sh) # HELP # This will output the help for each task # thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html .PHONY: help help: ## This help. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) .DEFAULT_GOAL := help # DOCKER TASKS # Build the container build: ## Build the container docker build -t $(APP_NAME) . build-nc: ## Build the container without caching docker build --no-cache -t $(APP_NAME) . run: ## Run container on port configured in `config.env` docker run -i -t --rm --env-file=./config.env -p=$(PORT):$(PORT) --name="$(APP_NAME)" $(APP_NAME) up: build run ## Run container on port configured in `config.env` (Alias to run) stop: ## Stop and remove a running container docker stop $(APP_NAME); docker rm $(APP_NAME) release: build-nc publish ## Make a release by building and publishing the `{version}` ans `latest` tagged containers to ECR # Docker publish publish: repo-login publish-latest publish-version ## Publish the `{version}` ans `latest` tagged containers to ECR publish-latest: tag-latest ## Publish the `latest` taged container to ECR @echo 'publish latest to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):latest publish-version: tag-version ## Publish the `{version}` taged container to ECR @echo 'publish $(VERSION) to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):$(VERSION) # Docker tagging tag: tag-latest tag-version ## Generate container tags for the `{version}` ans `latest` tags tag-latest: ## Generate container `{version}` tag @echo 'create tag latest' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):latest tag-version: ## Generate container `latest` tag @echo 'create tag $(VERSION)' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):$(VERSION) @@ -74,10 +83,9 @@ endif CMD_REPOLOGIN += " get-login \)" # login to AWS-ECR repo-login: ## Auto login to AWS-ECR unsing aws-cli @eval $(CMD_REPOLOGIN) version: ## Output the current version @echo $(VERSION) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ ### THIS IST THE VERSION WITH docker-compose # import config configfile=config.env ifdef cnf @@ -19,94 +18,88 @@ export $(shell sed 's/=.*//' $(deployfile)) # grep the version from the mix file VERSION=$(shell ./version.sh) # HELP # This will output the help for each task # thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html .PHONY: help help: ## This help. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) .DEFAULT_GOAL := help # DOCKER TASKS # Build the container build: ## Build the release and develoment container. The development docker-compose build --no-cache $(APP_NAME) docker-compose run $(APP_NAME) grunt build docker build -t $(APP_NAME) . run: stop ## Run container on port configured in `config.env` docker run -i -t --rm --env-file=./config.env -p=$(PORT):$(PORT) --name="$(APP_NAME)" $(APP_NAME) dev: ## Run container in development mode docker-compose build --no-cache $(APP_NAME) && docker-compose run $(APP_NAME) # Build and run the container up: ## Spin up the project docker-compose up --build $(APP_NAME) stop: ## Stop running containers docker stop $(APP_NAME) rm: stop ## Stop and remove running containers docker rm $(APP_NAME) clean: ## Clean the generated/compiles files echo "nothing clean ..." # Docker release - build, tag and push the container release: build publish ## Make a release by building and publishing the `{version}` ans `latest` tagged containers to ECR # Docker publish publish: repo-login publish-latest publish-version ## publish the `{version}` ans `latest` tagged containers to ECR publish-latest: tag-latest ## publish the `latest` taged container to ECR @echo 'publish latest to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):latest publish-version: tag-version ## publish the `{version}` taged container to ECR @echo 'publish $(VERSION) to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):$(VERSION) # Docker tagging tag: tag-latest tag-version ## Generate container tags for the `{version}` ans `latest` tags tag-latest: ## Generate container `{version}` tag @echo 'create tag latest' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):latest tag-version: ## Generate container `latest` tag @echo 'create tag $(VERSION)' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):$(VERSION) # HELPERS # generate script to login to aws docker repo CMD_REPOLOGIN := "aws ecr" ifdef AWS_CLI_PROFILE CMD_REPOLOGIN += "--profile $(AWS_CLI_PROFILE)" endif ifdef AWS_CLI_REGION CMD_REPOLOGIN += "--region $(AWS_CLI_REGION)" endif CMD_REPOLOGIN += "get-login" repo-login: ## auto login to AWS-ECR unsing aws-cli @echo $(CMD_REPOLOGIN) | sh | sed 's/-e none //' | sh version: ## output to version @echo $(VERSION) -
mpneuried revised this gist
Oct 31, 2016 . 1 changed file with 112 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,112 @@ ### THIS IST THE VERSION WITH docker-compose # import config configfile=config.env ifdef cnf configfile=$(cnf) endif include $(configfile) export $(shell sed 's/=.*//' $(configfile)) # import deploy config deployfile=deploy.env ifdef dpl deployfile=$(dpl) endif include $(deployfile) export $(shell sed 's/=.*//' $(deployfile)) # grep the version from the mix file VERSION=$(shell ./version.sh) # DOCKER TASKS # Build the container build: docker-compose build --no-cache $(APP_NAME) docker-compose run $(APP_NAME) grunt build docker build -t $(APP_NAME) . # Run container on port configured in `config.env` run: stop docker run -i -t --rm --env-file=./config.env -p=$(PORT):$(PORT) --name="$(APP_NAME)" $(APP_NAME) dev: docker-compose build --no-cache test && docker-compose run test # Build and run the container up: docker-compose up --build $(APP_NAME) stop: docker stop $(APP_NAME) rm: stop docker rm $(APP_NAME) tc=1 ifdef count tc=$(count) endif test: docker-compose build --no-cache test @if [ $(tc) = 1 ]; then\ docker-compose run test\ else\ docker-compose scale test=$(tc)\ docker-compose logs -f test\ fi test-live: docker-compose build --no-cache testlive @if [ $(tc) = 1 ]; then\ docker-compose run testlive\ else\ docker-compose scale testlive=$(tc)\ docker-compose logs -f testlive\ fi # Docker release - build, tag and push the container release: build publish # Docker publish publish: repo-login publish-latest publish-version publish-latest: tag-latest @echo 'publish latest to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):latest publish-version: tag-version @echo 'publish $(VERSION) to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):$(VERSION) # Docker tagging tag: tag-latest tag-version tag-latest: @echo 'create tag latest' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):latest tag-version: @echo 'create tag $(VERSION)' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):$(VERSION) # HELPERS # generate script to login to aws docker repo CMD_REPOLOGIN := "eval $$\( aws ecr" ifdef AWS_CLI_PROFILE CMD_REPOLOGIN += " --profile $(AWS_CLI_PROFILE)" endif ifdef AWS_CLI_REGION CMD_REPOLOGIN += " --region $(AWS_CLI_REGION)" endif CMD_REPOLOGIN += " get-login \)" # login to AWS-ECR repo-login: @eval $(CMD_REPOLOGIN) # output to version version: @echo $(VERSION) -
mpneuried revised this gist
Oct 27, 2016 . 2 changed files with 16 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,18 @@ # import config configfile=config.env ifdef cnf configfile=$(cnf) endif include $(configfile) export $(shell sed 's/=.*//' $(configfile)) # import deploy config deployfile=deploy.env ifdef dpl deployfile=$(dpl) endif include $(deployfile) export $(shell sed 's/=.*//' $(deployfile)) # grep the version from the mix file VERSION=$(shell ./version.sh) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,7 @@ make run make up # Stop the running container make stop # Build the container with differnt config and deploy file make cnf=another_config.env dpl=another_deploy.env build -
mpneuried revised this gist
Oct 13, 2016 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ build-nc: # Run container on port configured in `config.env` run: docker run -i -t --rm --env-file=./config.env -p=$(PORT):$(PORT) --name="$(APP_NAME)" $(APP_NAME) # Build and run the container up: build run This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,5 +19,5 @@ make run # Build an run the container make up # Stop the running container make stop -
mpneuried revised this gist
Oct 13, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,11 +36,11 @@ publish: repo-login publish-latest publish-version publish-latest: tag-latest @echo 'publish latest to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):latest publish-version: tag-version @echo 'publish $(VERSION) to $(DOCKER_REPO)' docker push $(DOCKER_REPO)/$(APP_NAME):$(VERSION) # Docker tagging tag: tag-latest tag-version -
mpneuried revised this gist
Oct 13, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # You have to define the values in {} APP_NAME=my-super-app DOCKER_REPO={account-nr}.dkr.ecr.{region}.amazonaws.com # optional aws-cli options -
mpneuried revised this gist
Oct 13, 2016 . 2 changed files with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,8 @@ # INSTALL # - copy the files deploy.env, config.env, version.sh and Makefile to your repo # - replace the vars in deploy.env # - define the version script # Build the container make build This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ # Example version script. # Please choose one version or create your own # Node.js: grep the version from a package.json file with jq jq -rM '.version' package.json # Elixir: grep the version from a mix file cat mix.exs | grep version | grep '\([0-9]\+\.\?\)\{3\}' -o -
mpneuried created this gist
Oct 13, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,75 @@ # import config include config.env export $(shell sed 's/=.*//' config.env) # import deploy config include deploy.env export $(shell sed 's/=.*//' deploy.env) # grep the version from the mix file VERSION=$(shell ./version.sh) # DOCKER TASKS # Build the container build: docker build -t $(APP_NAME) . # Build the container without cache build-nc: docker build --no-cache -t $(APP_NAME) . # Run container on port configured in `config.env` run: docker run --env-file=./config.env -p=$(PORT):$(PORT) --name="$(APP_NAME)" $(APP_NAME) # Build and run the container up: build run stop: docker stop $(APP_NAME); docker rm $(APP_NAME) # Docker release - build, tag and push the container release: build-nc publish # Docker publish publish: repo-login publish-latest publish-version publish-latest: tag-latest @echo 'publish latest to $(DOCKER_REPO)' docker push $(DOCKER_REPO):latest publish-version: tag-version @echo 'publish $(VERSION) to $(DOCKER_REPO)' docker push $(DOCKER_REPO):$(VERSION) # Docker tagging tag: tag-latest tag-version tag-latest: @echo 'create tag latest' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):latest tag-version: @echo 'create tag $(VERSION)' docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):$(VERSION) # HELPERS # generate script to login to aws docker repo CMD_REPOLOGIN := "eval $$\( aws ecr" ifdef AWS_CLI_PROFILE CMD_REPOLOGIN += " --profile $(AWS_CLI_PROFILE)" endif ifdef AWS_CLI_REGION CMD_REPOLOGIN += " --region $(AWS_CLI_REGION)" endif CMD_REPOLOGIN += " get-login \)" # login to AWS-ECR repo-login: @eval $(CMD_REPOLOGIN) # output to version version: @echo $(VERSION) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # Port to run the container PORT=4000 # Until here you can define all the individual configurations for your app This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ # You have to define teh values in {} APP_NAME=my-super-app DOCKER_REPO={account-nr}.dkr.ecr.{region}.amazonaws.com # optional aws-cli options AWS_CLI_PROFILE={aws-cli-profile} AWS_CLI_REGION={aws-cli-region} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ # Build the container make build # Build and publish the container make release # Publish a container to AWS-ECR. # This includes the login to the repo make publish # Run the container make run # Build an run the container make up # Stop the running container (needs to executed in a seperate shell) make stop This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # grep the version from a mix file cat mix.exs | grep version | grep '\([0-9]\+\.\?\)\{3\}' -o # grep the version from a package.json file with jq jq -rM '.version' package.json