DRUN := docker run --rm -e GO111MODULE=off -v "$(shell pwd)":/go/src/code.justin.tv/video-coreservices/tf-io-puppet-staged-deploy -w /go/src/code.justin.tv/video-coreservices/tf-io-puppet-staged-deploy public.ecr.aws/bitnami/golang:1.16
PUPPET_ENVIRONMENT=production
CODEDEPLOY_REGION=''

.PHONY: all clean build test output

all: clean build test output

clean:
	rm -rf output
	rm -f puppet-deploy.zip artifact/scripts/*.environment artifact/scripts/spmu
build:
	mkdir -p output
	${DRUN} go build -v -o output/spmu ./spmu/cmd/main.go
test:
	${DRUN} go test -v ./spmu/...
output: build test
	@echo "export PUPPET_ENVIRONMENT=${PUPPET_ENVIRONMENT}\nexport CODEDEPLOY_REGION=${CODEDEPLOY_REGION}" > artifact/scripts/application_start.sh.environment
	mv output/spmu artifact/scripts/spmu
	cd artifact && zip ../puppet-deploy.zip scripts/* appspec.yml
	
