Skip to content

Instantly share code, notes, and snippets.

@mhemmings
Last active January 9, 2021 05:40
Show Gist options
  • Save mhemmings/8bce047f60d8891954f406add0ee255d to your computer and use it in GitHub Desktop.
Save mhemmings/8bce047f60d8891954f406add0ee255d to your computer and use it in GitHub Desktop.
EB Deploy Makefile
VERSION=$(shell git rev-parse --short HEAD)
DESC=$(shell git log -1 --pretty=%B)
BUCKET_NAME="your-eb-s3-bucket"
PROJECT_NAME=$(shell basename $(shell pwd))
REGION="eu-west-1"
ifndef ENV
$(error No environment ENV is defined)
endif
test:
go fmt
go vet
go test
build:
GOOS=linux GOARCH=amd64 go build -o build/queue_processor main.go
archive:
zip -j $(VERSION).zip build/queue_processor Procfile
create_version:
aws s3 cp $(VERSION).zip s3://$(BUCKET_NAME)/$(PROJECT_NAME)/
aws elasticbeanstalk create-application-version --application-name $(PROJECT_NAME) --description "$(DESC)" --version-label $(VERSION) --source-bundle S3Bucket=$(BUCKET_NAME),S3Key="$(PROJECT_NAME)/$(VERSION).zip" --region $(REGION)
update_environment:
aws elasticbeanstalk update-environment --environment-name $(ENV) --version-label $(VERSION) --region $(REGION)
clean:
rm -rf build/ $(VERSION).zip
deploy: test build archive create_version update_environment clean
.PHONY: test build archive create_version update_environment clean deploy
queue_process: queue_processor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment