Deploying to Elastic Beanstalk

Deploying to Elastic Beanstalk

Enhance your project Makefile in the project directory with the following content:

.PHONY: .elasticbeanstalk/config.yml
.elasticbeanstalk/config.yml: guard-STAGE
	mkdir -p .elasticbeanstalk
	printf "global:\n  application_name: $(SERVICE)-$(STAGE)-app\n  default_region: $(AWS_REGION)\n  workspace_type: Application\n" > .elasticbeanstalk/config.yml

.PHONY: Dockerrun.aws.json
Dockerrun.aws.json:
	printf '{"AWSEBDockerrunVersion":"1","Image":{"Name":"%s","Update":"false"},"Ports":[{"ContainerPort":"8080"}]}' $(DOCKER_IMAGE) > Dockerrun.aws.json

.PHONY: deploy
deploy: .elasticbeanstalk/config.yml Dockerrun.aws.json guard-STAGE
	eb deploy $(STAGE)-active -r $(AWS_REGION) -l $(VERSION)

Create a new file .ebignore with the following content:

/.idea/
/.gradle/
/.git/

/build/
/cloudformation/
/docker/
/gradle/
/out/
/src/
/venv/

/Makefile
/README.md
/build.gradle
/buildspec.yml
/code.zip
/docker-compose.yml
/docker-run.sh
/gradlew
/secret.txt
/settings.gradle

Additionally enhance your .gitignore file as follows:

/Dockerrun.aws.json
/.elasticbeanstalk/

Deploy with the following command in the app-staging AWS account

AWS_EB_PROFILE=myorg-app-staging make deploy STAGE=dev